Getting date from user input.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Getting date from user input.

Post by CAsba » Tue Feb 07, 2023 1:56 pm

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 ?

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Getting date from user input.

Post by Klaus » Tue Feb 07, 2023 2:01 pm

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?

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Getting date from user input.

Post by Klaus » Tue Feb 07, 2023 3:15 pm

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...

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Re: Getting date from user input.

Post by CAsba » Wed Feb 08, 2023 11:20 am

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.

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Getting date from user input.

Post by AndyP » Wed Feb 08, 2023 11:46 am

Hi, have a look at this thread, see if it helps.

https://forums.livecode.com/viewtopic.p ... er#p196089
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Re: Getting date from user input.

Post by CAsba » Wed Feb 08, 2023 11:56 am

Thanks AndyP for your interest. I don't want to use the Calendar, it's a question of maintaining a consistent presentation. Thanks, anyway..

CAsba
Posts: 363
Joined: Fri Sep 30, 2022 12:11 pm

Re: Getting date from user input.

Post by CAsba » Wed Feb 08, 2023 12:34 pm

Many thanks to all - I just realised I was using "/" when it should have been "\".

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”