sql
-
I required only time in select query from datetime field in format like: 2:20:55 AM. Pls help me
-
I required only time in select query from datetime field in format like: 2:20:55 AM. Pls help me
That is presentation logic, use your presentation layer to format a datetime instance appropriately. This should start you off:
var now = DateTime.Now;
Console.WriteLine(now.ToString("h:mm:ss"));More info: Date / Time format strings[^] edit: read the forum guidlines for posting messages; pay specific attention to the subject line requirements.
-
I required only time in select query from datetime field in format like: 2:20:55 AM. Pls help me
There are a number of ways you can do this. Here is one:
select convert(nvarchar, getdate(), 8) TheTime
Here is another:
select substring(convert(nvarchar, getdate(), 22), 10, 11) TheTime
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
That is presentation logic, use your presentation layer to format a datetime instance appropriately. This should start you off:
var now = DateTime.Now;
Console.WriteLine(now.ToString("h:mm:ss"));More info: Date / Time format strings[^] edit: read the forum guidlines for posting messages; pay specific attention to the subject line requirements.
He may have a specific (and valid) reason for needing times in his sql.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
He may have a specific (and valid) reason for needing times in his sql.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
I highly doubt it. See his post below this one. In addition, I cannot think of a valid reason to format a date, or time, into a string in sql. can you?
I don't have a problem with the splitting of the date/time I can think of a number of valid reasons to do that in SQL. What had I missed was that he had stored the data as text, I assumed it was datetime.
Never underestimate the power of human stupidity RAH