Showing posts with label military. Show all posts
Showing posts with label military. Show all posts

Thursday, March 8, 2012

Date formating - Military

Hello all,

I am trying to import an excel spreadsheet that has a specific date column. The column is saved as military time. For example, one of the records is:

04-12-2007 09:30

But, when i import the data into sql 2005, the above date is displayed as:

2007-04-12 09:30

I need it to display like the same way that it's being displayed in the excel spreadsheet.

My field in sql is nvarchar(100) and it still doesn't work.

Any ideas?
Thanks in advance.

Hi Friend,

You can play with the data at UI Level while binding the data you can change the Date Format as you wish, by the way are u using GridView to show the records ??

|||Hi You can also refer to http://support.microsoft.com/kb/173907Thanks...Akhil|||

Nvarchar for dates is not recommended. You will not be able to sort by date or perform any date calculations, because your value will be treated as text. The recommended format for dates in Sql Server is YYYY-MM-DD hh:mm:ss. Once you extract a date/time value for display, you can fomat it in any way you want using the String.Format() method. Here are the expressions used to generate custom formats:http://blog.stevex.net/index.php/string-formatting-in-csharp/. The page is for C#, but the expressions are equally valid for VB.


Tuesday, February 14, 2012

Date and Time Output

I have a SQL statement creating an output of date and time, I would like to
show the time in military. The output I receive is in AM/PM.
How to generate the a military display?
Thank you
See Books Online "CAST and CONVERT".
Mike
"robert_at_cbb" wrote:

> I have a SQL statement creating an output of date and time, I would like to
> show the time in military. The output I receive is in AM/PM.
> How to generate the a military display?
> Thank you
|||I did look in books online, but I still get the AM/PM. Could you provide an
example i might be able to use.
"Mike" wrote:
[vbcol=seagreen]
> See Books Online "CAST and CONVERT".
> Mike
> "robert_at_cbb" wrote:
|||select convert (char (30), getdate(), 14)
Styles 13, 14, 20 and 21 all return 24h time with various formats for the
date portion. The trick is getting the length for char() long enough (too
short will truncate the results) and the correct style number.
Mike
"robert_at_cbb" wrote:
[vbcol=seagreen]
> I did look in books online, but I still get the AM/PM. Could you provide an
> example i might be able to use.
> "Mike" wrote:
|||http://www.aspfaq.com/2464
http://www.aspfaq.com/
(Reverse address to reply.)
"robert_at_cbb" <robertatcbb@.discussions.microsoft.com> wrote in message
news:531FFB92-520B-4A0A-9A6E-154096346D6A@.microsoft.com...
> I have a SQL statement creating an output of date and time, I would like
to
> show the time in military. The output I receive is in AM/PM.
> How to generate the a military display?
> Thank you

Date and Time Output

I have a SQL statement creating an output of date and time, I would like to
show the time in military. The output I receive is in AM/PM.
How to generate the a military display?
Thank youSee Books Online "CAST and CONVERT".
Mike
"robert_at_cbb" wrote:

> I have a SQL statement creating an output of date and time, I would like t
o
> show the time in military. The output I receive is in AM/PM.
> How to generate the a military display?
> Thank you|||I did look in books online, but I still get the AM/PM. Could you provide an
example i might be able to use.
"Mike" wrote:
[vbcol=seagreen]
> See Books Online "CAST and CONVERT".
> Mike
> "robert_at_cbb" wrote:
>|||select convert (char (30), getdate(), 14)
Styles 13, 14, 20 and 21 all return 24h time with various formats for the
date portion. The trick is getting the length for char() long enough (too
short will truncate the results) and the correct style number.
Mike
"robert_at_cbb" wrote:
[vbcol=seagreen]
> I did look in books online, but I still get the AM/PM. Could you provide a
n
> example i might be able to use.
> "Mike" wrote:
>|||http://www.aspfaq.com/2464
http://www.aspfaq.com/
(Reverse address to reply.)
"robert_at_cbb" <robertatcbb@.discussions.microsoft.com> wrote in message
news:531FFB92-520B-4A0A-9A6E-154096346D6A@.microsoft.com...
> I have a SQL statement creating an output of date and time, I would like
to
> show the time in military. The output I receive is in AM/PM.
> How to generate the a military display?
> Thank you

Date and Time Output

I have a SQL statement creating an output of date and time, I would like to
show the time in military. The output I receive is in AM/PM.
How to generate the a military display?
Thank youSee Books Online "CAST and CONVERT".
Mike
"robert_at_cbb" wrote:
> I have a SQL statement creating an output of date and time, I would like to
> show the time in military. The output I receive is in AM/PM.
> How to generate the a military display?
> Thank you|||I did look in books online, but I still get the AM/PM. Could you provide an
example i might be able to use.
"Mike" wrote:
> See Books Online "CAST and CONVERT".
> Mike
> "robert_at_cbb" wrote:
> > I have a SQL statement creating an output of date and time, I would like to
> > show the time in military. The output I receive is in AM/PM.
> >
> > How to generate the a military display?
> >
> > Thank you|||select convert (char (30), getdate(), 14)
Styles 13, 14, 20 and 21 all return 24h time with various formats for the
date portion. The trick is getting the length for char() long enough (too
short will truncate the results) and the correct style number.
Mike
"robert_at_cbb" wrote:
> I did look in books online, but I still get the AM/PM. Could you provide an
> example i might be able to use.
> "Mike" wrote:
> > See Books Online "CAST and CONVERT".
> >
> > Mike
> >
> > "robert_at_cbb" wrote:
> >
> > > I have a SQL statement creating an output of date and time, I would like to
> > > show the time in military. The output I receive is in AM/PM.
> > >
> > > How to generate the a military display?
> > >
> > > Thank you|||http://www.aspfaq.com/2464
--
http://www.aspfaq.com/
(Reverse address to reply.)
"robert_at_cbb" <robertatcbb@.discussions.microsoft.com> wrote in message
news:531FFB92-520B-4A0A-9A6E-154096346D6A@.microsoft.com...
> I have a SQL statement creating an output of date and time, I would like
to
> show the time in military. The output I receive is in AM/PM.
> How to generate the a military display?
> Thank you