SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Date time conversion.


Date time conversion.

Author
Message
wwright 50911
wwright 50911
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 11
I am working on an SSRS report and the query I am using returns a date time value of '2018-01-01 11:07:12.000'. I need to display only the hours and minutes and the format using this example would be 1107. I tried using datepart(sql) and concatenating the two values but datepart returns an integer value and drops the leading 0 in the minutes. Thank You!
Luis Cazares
Luis Cazares
SSC Guru
SSC Guru (162K reputation)SSC Guru (162K reputation)SSC Guru (162K reputation)SSC Guru (162K reputation)SSC Guru (162K reputation)SSC Guru (162K reputation)SSC Guru (162K reputation)SSC Guru (162K reputation)

Group: General Forum Members
Points: 162182 Visits: 22746
wwright 50911 - Friday, February 9, 2018 10:29 AM
I am working on an SSRS report and the query I am using returns a date time value of '2018-01-01 11:07:12.000'. I need to display only the hours and minutes and the format using this example would be 1107. I tried using datepart(sql) and concatenating the two values but datepart returns an integer value and drops the leading 0 in the minutes. Thank You!


Have you tried the FORMAT function? To be clear, the one on SSRS not on T-SQL.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
wwright 50911
wwright 50911
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 11
Yes I have. I am going to close this post. I get the dum ass of the day award. After I made the post I got to looking at the table and discovered what I was looking for already had a column for time in the format I needed.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search