Time display

L

Lp12

Hi All,
I'm a newbie in this and i built up a simple form and published it into a
WSS site.
The form contains several DateTime fields that i've formated them to
dd/mm/yyyy and time hh:mm:ss AMPM. (i've picked out of the format list).
When i preview the form and hitting one of the date picker objects i get the
exact date but the hour comes: 00:00. Why?? Any suggestions?
Thanks in advance
 
B

Brian Teutsch [MSFT]

Unfortunately this is the current behavior of InfoPath. Date Pickers will
not function well with dateTime node types. There really isn't a workaround,
other than to use a Plain Text Box, and add formatting to show the date and
time in user-friendly format.

Sorry,
Brian
 
N

Nic Roche

other than to use a Plain Text Box,

You can still use the Date Picker, then parse the NewValue in the
onafterchange event to add the correct time and assign the new value
directly to the DOM.

This will fire the onafterchange event again, so filter for recursion.

Nic Roche
 
B

Brian Teutsch [MSFT]

Brilliant. Difficult, but brilliant.

Nic Roche said:
You can still use the Date Picker, then parse the NewValue in the
onafterchange event to add the correct time and assign the new value
directly to the DOM.

This will fire the onafterchange event again, so filter for recursion.

Nic Roche
 
L

Lp12

Thanks a lot for the tip. but i see that i need the skills to write JS right?
Can you advise me how to start learning that? I develop in VBA and VB6.
Thanks a lot
 
B

Brian Teutsch [MSFT]

This will be quite difficult to do if you aren't completely comfortable with
code. You could parse the old value for the XML dateTime seperator, "T".
Then you could append the portion after the "T" onto the newValue. I can't
suggest the VB code to do it, but it should be mostly string.indexOf
functions.

Brian
 
N

Nic Roche

Can you advise me how to start learning that?

One way to learn is to set goals. use existing code, and try to understand
what you are doing:

'CODE IN VBS
'Right-click Date Picker > Properties > Data Validation > Events >
OnAfterChange > Edit
'Replace your xpath in OnAfterChange
'Add Sub DateWithTime
'Use Text DataType for Date Picker

Sub msoxd__dateTimeCreated_attr_OnAfterChange(eventObj)
If Len( eventObj.NewValue ) < 11 Then
XDocument.DOM.selectSingleNode(
"/TestCase/Details/@dateTimeCreated" ).Text = DateWithTime(
eventObj.NewValue )
Else
Exit Sub
End If
If eventObj.IsUndoRedo Then
Exit Sub
End If
End Sub

Function DateWithTime( vsDate )
DateWithTime = Left( vsDate, 10 ) & " " & Time
End Function

Nic Roche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top