irene79
asked on
Getting the correct format of Date
I have a field in DateTime format. if the user choose today's date, the field will show "22/06/2001" but when i get the value from my code, it shows me "06/22/2001" as a result, i encounter an error when i do the following :
FromDate = Datenumber(Year(From), Month(From), Day(From))
I've checked the regional settings, the date format is "dd/MM/yyyy". is there any way that i can get the value of the date and force it to be formatted to "dd/MM/yyyy"?
Thanks.
FromDate = Datenumber(Year(From), Month(From), Day(From))
I've checked the regional settings, the date format is "dd/MM/yyyy". is there any way that i can get the value of the date and force it to be formatted to "dd/MM/yyyy"?
Thanks.
ASKER
i've tried using format to format it. but it did not work. the output is still "06/22/2001 12:00:00 AM"
Can you show me the code for using the international settings and the splitting?
Can you show me the code for using the international settings and the splitting?
Did you also check the servers settings ?
Did you check the fields properties, does he use custom settings or system settings ?
Here's a link to a question with almost the same problem
https://www.experts-exchange.com/jsp/qShow.jsp?ta=lotusnotes&qid=20121730
Greets,
Sloeber
Did you check the fields properties, does he use custom settings or system settings ?
Here's a link to a question with almost the same problem
https://www.experts-exchange.com/jsp/qShow.jsp?ta=lotusnotes&qid=20121730
Greets,
Sloeber
I have worked with D/M/Y clients on M/D/Y servers before.
The solutions of splitting the date could work but isn't my first recommendation. As the problem may also occur in other applications in your organisation (now or in future...) I guess you want an easy-to-remember-solution!
Can you provide more detail? How to you retrieve the data from the date/time field and put it into "From"? I may be able to look a solution in my older work then.
One thing is sure: never trust the help regarding formula's accepting both D/M/Y and M/D/Y: how should in interprete 1/2/2001? 1st of Feb or 2nd of Jan?
The solutions of splitting the date could work but isn't my first recommendation. As the problem may also occur in other applications in your organisation (now or in future...) I guess you want an easy-to-remember-solution!
Can you provide more detail? How to you retrieve the data from the date/time field and put it into "From"? I may be able to look a solution in my older work then.
One thing is sure: never trust the help regarding formula's accepting both D/M/Y and M/D/Y: how should in interprete 1/2/2001? 1st of Feb or 2nd of Jan?
ASKER
here's my code :
Dim ws As New NotesUIWorkspace
Dim uidocCur As NotesUIDocument
Set uidocCur = ws.CurrentDocument
Dim sDateFrom As String
sDateFrom = uidocCur.FieldGetText("dat From")
"datFrom" is a field on the form of datetime type. not sure if tis info. is enuff. let me know if i need to provide more details.
Dim ws As New NotesUIWorkspace
Dim uidocCur As NotesUIDocument
Set uidocCur = ws.CurrentDocument
Dim sDateFrom As String
sDateFrom = uidocCur.FieldGetText("dat
"datFrom" is a field on the form of datetime type. not sure if tis info. is enuff. let me know if i need to provide more details.
You need to define sDateFrom as a Variant variable, this way it will contain your date as a date variable in script. Now when you set the datefield using this variable, it doesn't matter what format it was originally entered as. Notes will automatically format it the way it should.
BTW: For web applications Notes will always display the date according the server's Default User's international settings.
Regards,
BTW: For web applications Notes will always display the date according the server's Default User's international settings.
Regards,
So the error was a "Type mismatch", right?
I expected errors caused by month > 12....
Try:
Dim Ws As New NotesUIWorkspace
Dim UIDoc As NotesUIDocument
Set UIDoc = Ws.CurrentDocument
Dim sDateFrom As New NotesDateTime(UIDoc.FieldG etText("da tFrom"))
' additional handling to prove it's working
Call sDateFrom.AdjustDay(1)
Messagebox sDateFrom.LsLocalTime
I expected errors caused by month > 12....
Try:
Dim Ws As New NotesUIWorkspace
Dim UIDoc As NotesUIDocument
Set UIDoc = Ws.CurrentDocument
Dim sDateFrom As New NotesDateTime(UIDoc.FieldG
' additional handling to prove it's working
Call sDateFrom.AdjustDay(1)
Messagebox sDateFrom.LsLocalTime
Is your client Windows 95/98?
If it is, there is a setting in win.ini called idate=0.
Change the entry to be idate=1 and your fields will display as 22/6/2001.
idate=0 gives you the format 6/22/2001
Hope this helps
If it is, there is a setting in win.ini called idate=0.
Change the entry to be idate=1 and your fields will display as 22/6/2001.
idate=0 gives you the format 6/22/2001
Hope this helps
ASKER
CRAK: yes i got the error of type mismatch. will try your method and get back to you.
vqalvin : my client is windows95. but im trying to set the date format to dd/mm/yyyy without depending on the settings of the user's pc.
vqalvin : my client is windows95. but im trying to set the date format to dd/mm/yyyy without depending on the settings of the user's pc.
ASKER
CRAK: the sDateFrom.LsLocalTime works! does that mean that everytime i need to retrieve a date field from the form i have to use LsLocalTime? in my other date field, i will get a type mismatch error if i do not put LsLocaltime.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks CRAK!! :)
You're welcome!
Set FromDate = document.From(0)
Or use pre-format it as you request, using format:
FormattedFrom = format$(From, "dd/mm/yyyy")
Another option could be retrieving the clients international settings first through NotesSession.International