Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Today() function in date picker

178 views
Skip to first unread message

Martin Cabalzar

unread,
Mar 17, 2004, 3:30:35 AM3/17/04
to
Hi

It's a simple question... How can I set the date of a date picker field?

This doesn't works:
_doc.DOM.selectSingleNode("/my:myFields/my:MyDatePicker").nodeValue =
DateTime.Now.ToString("yyyy-mm-ddThh:mm:ss");

and this also:
_doc.DOM.selectSingleNode("/my:myFields/my:MyDatePicker").text =
DateTime.Now.ToString("yyyy-mm-ddThh:mm:ss");

I've tried a lot of other values, but nothing functions. I need to set a
date "one year ago", for example: Today()-365!

Thank you for replies...

Martin Cabalzar


David Fries [MSFT]

unread,
Mar 17, 2004, 1:34:37 PM3/17/04
to
In the SP1 preview build, you can use the "Insert Formula" dialog (found by
clicking the fx button in the date picker properties dialog) to insert a
now() or today() calculation.
Thanks,
Dave

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Sample code subject to http://www.microsoft.com/info/cpyright.htm
--


"Martin Cabalzar" <m.cab...@gmx.ch> wrote in message
news:%23$rcgo$CEHA...@tk2msftngp13.phx.gbl...

Jose Oliver-Didier [MSFT]

unread,
Mar 17, 2004, 1:40:46 PM3/17/04
to
Hi Martin:

If you want to set a default date value in the Date Picker Control you can
do this by:

1. In design mode, add a "Date Picker" Control
2. Right Click on the control and open the "Date Picker Properties" dialog.
3. Within the Properties dialog, click on the "Data" tab and specify a
default value on the "Default Value" text field.

If you want to specify today's date as the default value, for example, click
on the "Formula" icon and type "today()".

hope this helps,
- josé

Jose Oliver-Didier
Software Test Engineer
Microsoft Office InfoPath

Check out http://blogs.msdn.com/infopath for additional InfoPath tips and
tricks.

Please post questions to the newsgroup; everyone benefits.


This posting is provided "AS IS" with no warranties, and confers no rights.
Sample code subject to http://www.microsoft.com/info/cpyright.htm

"Martin Cabalzar" <m.cab...@gmx.ch> wrote in message
news:%23$rcgo$CEHA...@tk2msftngp13.phx.gbl...

Gary Hsu [MSFT]

unread,
Mar 17, 2004, 2:04:43 PM3/17/04
to
What error message did you get when you preview the form?

Where did you put the code snippet below for setting the date? In the
OnLoad handler?

The data type of a date picker by default, is date. Did you change it to
dateTime?

The date picker field is blank by default. Did you remove the xsi:nil
attribute from the field before setting it?

One more thing, you probably want "yyyy-MM-ddThh:mm:ss" so that you get
months instead of minutes in the format string.

Gary


"Martin Cabalzar" <m.cab...@gmx.ch> wrote in message
news:%23$rcgo$CEHA...@tk2msftngp13.phx.gbl...

Gary Hsu [MSFT]

unread,
Mar 17, 2004, 2:06:39 PM3/17/04
to
This is true, but there are no functions for manipulating dates (e.g.
subtract a year), so you must use code to do it.

"David Fries [MSFT]" <davf...@online.microsoft.com> wrote in message
news:Opb8$5EDEH...@tk2msftngp13.phx.gbl...

Martin Cabalzar

unread,
Mar 18, 2004, 3:48:26 AM3/18/04
to
Hi Gary

I've tried various date formats... the problem is still the same: I can't
access the date picker field programmatically. I can set the text of the
picker to a date, but there's always a dashed border around the box!

I don't receive an error message - it's just the dashed red border around
the box... I also tried formats like mm/dd/yyyy and so on, but it's still
the same problem.

Martin

P.S. The functions in the formula editor are very basic. I've to calculate
with dates and times - I cannot use the function today() only!


"Gary Hsu [MSFT]" <gar...@online.microsoft.com> wrote in message
news:udgq1KFD...@TK2MSFTNGP11.phx.gbl...

Gary Hsu [MSFT]

unread,
Mar 18, 2004, 1:14:10 PM3/18/04
to
1. Go to your date picker properties by double-clicking on it.
2. Look at the data type drop-down.

If the data type is "Date (date)", then the value of the field must be in
the form of "yyyy-MM-dd" in order for the date picker field to not have a
red dashed border around it. The red dashed border indicates that the field
has a validation error.

If the data type is "Date and Time (dateTime)", then the value must be in
the form of "yyyy-MM-ddThh:mm:ss".

I suspect you still have the data type set as "Date (date)". So if you set
the text of the field programmatically to "yyyy-MM-ddThh:mm:ss" format, it
will show the red dashed border.

You either change the data type to "Date and Time (dateTime)" or set the
field's text value to "yyyy-MM-dd" format.

Gary


"Martin Cabalzar" <m.cab...@gmx.ch> wrote in message

news:%2388AJXM...@TK2MSFTNGP11.phx.gbl...

Martin Cabalzar

unread,
Mar 19, 2004, 2:11:35 AM3/19/04
to
Yes, this works fine! Thank you very much!

Martin Cabalzar

"Gary Hsu [MSFT]" <gar...@online.microsoft.com> wrote in message

news:%23Y2BGTR...@TK2MSFTNGP09.phx.gbl...

0 new messages