Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PB 6 - Datetime conversion to int via sql

Status
Not open for further replies.

Jolane

MIS
Dec 14, 2004
2
0
0
ZA
Hi there,

I need to convert a datetime to an integer so that I can pass it to a sql stored procedure.

Can that be done?
 
What do you mean by 'convert a datetime to an integer'? Day of week?, day of month?, month?, year?, sum of above?
 
I basically need to convert a datetime to a julian date.
 
You can convert datatime "mm/dd/yyyy hh:mm" like '04/23/2005 15:41' into 042320051541 (if it solves your problem) by:
//=============================================
string ls_datetime = '04/23/2005 15:41'
string ls_month, ls_day, ls_year, ls_hour, ls_min
dec ldec_datetime1, ldec_datetime2

ls_month = left(ls_datetime,2)
ls_day = mid(ls_datetime,4,2)
ls_year = mid(ls_datetime,7,4)
ls_hour = mid(ls_datetime, 12,2)
ls_min = right(ls_datetime,2)

ldec_datetime1 = long(ls_year)*10000 + long(ls_hour)*100 + long(ls_min)
ldec_datetime2 = long(ls_month)*100 + long(ls_day)

MessageBox('',string(ldec_datetime2*100000000 + ldec_datetime1))
//===============================================

You get 42320051541.

Arnold

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top