combine a seperate date and seperate time field into 'yyyy-mm-dd hh:mm:ss'

Reply
Occasional Contributor
Posts: 14

combine a seperate date and seperate time field into 'yyyy-mm-dd hh:mm:ss'

i have a date field  say 'x'  length is 8

i have a time field  say 'y'  length is 8

z should contain  x + y  and z should be displayed as 'yyy-mm-dd hh:mm:ss'

Super User
Super User
Posts: 7,401

Re: combine a seperate date and seperate time field into 'yyyy-mm-dd hh:mm:ss'

Hi,

Well, is z a date/time variable or charcter?  If its character then do:

z = strip(put(date,yymmdd8.))||' '||strip(put(time,time8.)

If you want a datetime variable as output then do the same, convert both to character, add in any other characers you need for your specific format, then input that as the format.  Can't remember what the date 8 one is above, but for datetime20.:

z = input(strip(put(date,date9.))||':'||strip(put(time,time8.)),datetime20.)

Occasional Contributor
Posts: 14

Re: combine a seperate date and seperate time field into 'yyyy-mm-dd hh:mm:ss'

thanks it worked

Ask a Question
Discussion stats
  • 2 replies
  • 299 views
  • 0 likes
  • 2 in conversation