Page 1 of 1
Getting date from user input.
Posted: Tue Feb 07, 2023 1:56 pm
by CAsba
Hi,
I need to get dates from user input, but I don't want to use the Datepicker.
So far, I have managed to get the day month and year into a field with two "/" seperators, which gives the appearance of a date, like '23/6/2023'
My problem is that I cannot convert it to seconds in order to subtract the date field from the date in the 'today' field, into which I have 'put the date' (entered today's date).
Is there a way to do this ?
Re: Getting date from user input.
Posted: Tue Feb 07, 2023 2:01 pm
by Klaus
Just set the itemdelimiter to / and "swap" the first and second item.
Then you have an english date to let LC work with.
P.S.
Do you know how to do this?
Re: Getting date from user input.
Posted: Tue Feb 07, 2023 3:15 pm
by Klaus
No idea where you are from, but why not work with the date formats in your country?
We have ->
the system date etc. in LC!
Example:
I live in germany and ->
put the system date gives me: 07.02.23
And I can use this like this:
Code: Select all
convert "07.02.23" from SYSTEM date to seconds
Just an idea, maybe not working for you...
Re: Getting date from user input.
Posted: Wed Feb 08, 2023 11:20 am
by CAsba
Hi again,
Here's a bit more detail re my problem..
The code is:
Code: Select all
local tDate, tDate2, tDifference
set the itemdelimiter to "\"
put field "startmth" & "\" & field "startday" & "\" & field "startyr" into field "date1"
put fld "date1" && "12:00 PM" into tdate
convert tdate to seconds
put tdate into fld "field2"
Startmth, startday and startyr are user inputs.
In field2 I get '4/3/23 12.00pm'. It looks like a date, but does not convert to seconds, so it cannot be used as a date, to be compared with 'today' to indicate if it is in the future or past.
Re: Getting date from user input.
Posted: Wed Feb 08, 2023 11:46 am
by AndyP
Re: Getting date from user input.
Posted: Wed Feb 08, 2023 11:56 am
by CAsba
Thanks AndyP for your interest. I don't want to use the Calendar, it's a question of maintaining a consistent presentation. Thanks, anyway..
Re: Getting date from user input.
Posted: Wed Feb 08, 2023 12:34 pm
by CAsba
Many thanks to all - I just realised I was using "/" when it should have been "\".