Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Help!!!

4 posts in Windows NT Last posting was on 2000-06-21 16:57:55.0Z
Michael Ernst Posted on 2000-06-20 19:24:34.0Z
From: "Michael Ernst" <ernstmik@umich.edu>
Subject: Help!!!
Date: Tue, 20 Jun 2000 15:24:34 -0400
Lines: 7
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <LfKgw5u2$GA.203@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: host-218.subnet-154.med.umich.edu 141.214.154.218
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1997
Article PK: 1089445

I need help with a piece of code that will convert the time part from a
smalldatetime datatype from 24 hr time to am/pm time. I believe that I need
to start the code like this: convert(int(datepartpart(hh, start_datetime))).
I think I have gotten that far but from there I am stuck. Please help, I
would like to see an example in SQL and VB. Thanks a million.


Andy Price Posted on 2000-06-20 22:24:47.0Z
From: "Andy Price" <andy.price@canada.com>
References: <LfKgw5u2$GA.203@forums.sybase.com>
Subject: Re: Help!!!
Date: Tue, 20 Jun 2000 23:24:47 +0100
Lines: 49
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
Message-ID: <9vRyNew2$GA.285@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: dyn101-ras30.screaming.net 212.49.253.101
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1995
Article PK: 1089446

Michael,

To get the time in AM/PM format, you can use date format 109 with the
convert function. With a smalldatetime datatype, you get the date
and time in the following format:

Jun 20 2000 11:14PM

To get the 12 hour clock from a smalldatetime, you can use the style
109 with the convert function. So if we have a table called hello,
with one column (col1) as a smalldatetime, and do a select from
it, converting to style 109, we get the following of 26 characters:

Jun 20 2000 11:14:00:000PM

So we can get the time back in 12 hour format (11:14) thus:

select substring(convert(varchar(26), col1, 109), 13, 5) from hello

To add the AM/PM on the end, we add a second substring giving the full
select statement as:

select substring(convert(varchar(26), col1, 109), 13, 5) +
substring(convert(varchar(26), col1, 109), 25, 2)
from hello

The above statement returned: 11:14PM

Hope that helped.

--
Andy Price
Sybase Certified Adaptive Server Administrator - Associate v11.5

"Michael Ernst" <ernstmik@umich.edu> wrote in message
news:LfKgw5u2$GA.203@forums.sybase.com...
> I need help with a piece of code that will convert the time part from a
> smalldatetime datatype from 24 hr time to am/pm time. I believe that I
need
> to start the code like this: convert(int(datepartpart(hh,
start_datetime))).
> I think I have gotten that far but from there I am stuck. Please help, I
> would like to see an example in SQL and VB. Thanks a million.
>
>


Michael Ernst Posted on 2000-06-21 15:35:32.0Z
From: "Michael Ernst" <ernstmik@umich.edu>
References: <LfKgw5u2$GA.203@forums.sybase.com> <9vRyNew2$GA.285@forums.sybase.com>
Subject: Re: Help!!!
Date: Wed, 21 Jun 2000 11:35:32 -0400
Lines: 59
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <43tgMe52$GA.86@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: host-218.subnet-154.med.umich.edu 141.214.154.218
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1984
Article PK: 1089433

Thanks for the help. It worked great. Is there a list somewhere of the
style codes and what they mean?

Mike Ernst

"Andy Price" <andy.price@canada.com> wrote in message
news:9vRyNew2$GA.285@forums.sybase.com...
> Michael,
>
> To get the time in AM/PM format, you can use date format 109 with the
> convert function. With a smalldatetime datatype, you get the date
> and time in the following format:
>
> Jun 20 2000 11:14PM
>
> To get the 12 hour clock from a smalldatetime, you can use the style
> 109 with the convert function. So if we have a table called hello,
> with one column (col1) as a smalldatetime, and do a select from
> it, converting to style 109, we get the following of 26 characters:
>
> Jun 20 2000 11:14:00:000PM
>
> So we can get the time back in 12 hour format (11:14) thus:
>
> select substring(convert(varchar(26), col1, 109), 13, 5) from hello
>
> To add the AM/PM on the end, we add a second substring giving the full
> select statement as:
>
> select substring(convert(varchar(26), col1, 109), 13, 5) +
> substring(convert(varchar(26), col1, 109), 25, 2)
> from hello
>
> The above statement returned: 11:14PM
>
> Hope that helped.
>
> --
> Andy Price
> Sybase Certified Adaptive Server Administrator - Associate v11.5
>
>
>
> "Michael Ernst" <ernstmik@umich.edu> wrote in message
> news:LfKgw5u2$GA.203@forums.sybase.com...
> > I need help with a piece of code that will convert the time part from a
> > smalldatetime datatype from 24 hr time to am/pm time. I believe that I
> need
> > to start the code like this: convert(int(datepartpart(hh,
> start_datetime))).
> > I think I have gotten that far but from there I am stuck. Please help,
I
> > would like to see an example in SQL and VB. Thanks a million.
> >
> >
>
>


Andy Price Posted on 2000-06-21 16:57:55.0Z
From: "Andy Price" <andy.price@canada.com>
References: <LfKgw5u2$GA.203@forums.sybase.com> <9vRyNew2$GA.285@forums.sybase.com> <43tgMe52$GA.86@forums.sybase.com>
Subject: Re: Help!!!
Date: Wed, 21 Jun 2000 17:57:55 +0100
Lines: 74
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
Message-ID: <qa3MeM62$GA.279@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: dyn223-ras29.screaming.net 212.49.252.223
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:1982
Article PK: 1089426

Yes, in the Sybase Reference Manual do a search for "convert function", and
you can see them all in the table "Display formats for date/time
information" (in Sybase 12 manuals it is table 2-4).

Andy

"Michael Ernst" <ernstmik@umich.edu> wrote in message
news:43tgMe52$GA.86@forums.sybase.com...
> Thanks for the help. It worked great. Is there a list somewhere of the
> style codes and what they mean?
>
> Mike Ernst
>
> "Andy Price" <andy.price@canada.com> wrote in message
> news:9vRyNew2$GA.285@forums.sybase.com...
> > Michael,
> >
> > To get the time in AM/PM format, you can use date format 109 with the
> > convert function. With a smalldatetime datatype, you get the date
> > and time in the following format:
> >
> > Jun 20 2000 11:14PM
> >
> > To get the 12 hour clock from a smalldatetime, you can use the style
> > 109 with the convert function. So if we have a table called hello,
> > with one column (col1) as a smalldatetime, and do a select from
> > it, converting to style 109, we get the following of 26 characters:
> >
> > Jun 20 2000 11:14:00:000PM
> >
> > So we can get the time back in 12 hour format (11:14) thus:
> >
> > select substring(convert(varchar(26), col1, 109), 13, 5) from hello
> >
> > To add the AM/PM on the end, we add a second substring giving the full
> > select statement as:
> >
> > select substring(convert(varchar(26), col1, 109), 13, 5) +
> > substring(convert(varchar(26), col1, 109), 25, 2)
> > from hello
> >
> > The above statement returned: 11:14PM
> >
> > Hope that helped.
> >
> > --
> > Andy Price
> > Sybase Certified Adaptive Server Administrator - Associate v11.5
> >
> >
> >
> > "Michael Ernst" <ernstmik@umich.edu> wrote in message
> > news:LfKgw5u2$GA.203@forums.sybase.com...
> > > I need help with a piece of code that will convert the time part from
a
> > > smalldatetime datatype from 24 hr time to am/pm time. I believe that
I
> > need
> > > to start the code like this: convert(int(datepartpart(hh,
> > start_datetime))).
> > > I think I have gotten that far but from there I am stuck. Please
help,
> I
> > > would like to see an example in SQL and VB. Thanks a million.
> > >
> > >
> >
> >
>
>