Page 1 of 1

Proc to get datevalue from "21/02/2015", "23:59:59" params

Posted: Wed Oct 21, 2015 10:35 pm
by Zebuddi123
Hi to all I have a sql db that i needed to add a new table from existing date and a time table in different formats ( "21/02/2015", "23:59:59" ) so i came up with this little Procedure so i can quickly run through the db and and create and add the new table from the existing. It might be useful to others so thought I`d share.

Zebuddi. :)

Code: Select all

Procedure.i GetLongDate(date.s, date_delimeter.s, time.s, time_delimeter.s) 
	Macro _mSF(string, index, delimeter)
		Val(StringField(String, index, delimeter))
	EndMacro
	ProcedureReturn  Date(_mSF(date,3,date_delimeter),_mSF(date,2,date_delimeter),_mSF(date,1,date_delimeter),_mSF(time,1,time_delimeter),_mSF(time,2,time_delimeter),_mSF(time,3,time_delimeter))
EndProcedure


Example: 
nd = GetLongDate("21/02/2015", "/", "23:59:59", ":")

Debug nd
Debug FormatDate("%dd,%mm,%yyyy,%hh,%ii,%ss",nd )

Re: Proc to get datevalue from "21/02/2015", "23:59:59" para

Posted: Wed Oct 21, 2015 11:12 pm
by StarBootics
I'm not sure to fully understand what you want to do but a simple ParseDate() will do the same thing :

Code: Select all

Debug ParseDate("%dd/%mm/%yyyy, %hh:%ii:%ss", "21/02/2015, 23:59:59")


Best regards
StarBootics

Re: Proc to get datevalue from "21/02/2015", "23:59:59" para

Posted: Wed Oct 21, 2015 11:21 pm
by Zebuddi123
Hi StarBootics Doh cant believe I missed that :oops: :lol: Thanks at least I learned something in the process "to put my brain in gear first" lol

I assumed :oops: the delimiter`s were fixed :lol: in parsedate() as I don't ever remember using it only quickly read about, as i just found out and tested they can be virtually anything even omitted.

Zebuddi. :)