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.

How to convert date to string

6 posts in General Discussion Last posting was on 2004-02-25 16:16:22.0Z
Chandresh Patel Posted on 2004-02-24 23:10:00.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
Subject: How to convert date to string
Lines: 15
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: aca8b22b.ipt.aol.com
Message-ID: <403bd9d7$1@forums-2-dub>
X-Original-Trace: 24 Feb 2004 15:10:15 -0800, aca8b22b.ipt.aol.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 24 Feb 2004 15:09:28 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 24 Feb 2004 15:10:00 -0800
X-Trace: forums-1-dub 1077664200 10.22.108.75 (24 Feb 2004 15:10:00 -0800)
X-Original-Trace: 24 Feb 2004 15:10:00 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2625
Article PK: 6097

Hi,

Sybase Anywhere 9.0.0.1108

I have two date variable in my procedure and i want to create one string and
insert in to database varchar(30) field.

I want string like : "2/22/2004 To 2/28/2004" and this value i want to
insert in table as a string.

How do i do this.

Thanks in Advance.


Breck Carter [TeamSybase] Posted on 2004-02-24 23:32:59.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: How to convert date to string
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com>
References: <403bd9d7$1@forums-2-dub>
X-Newsreader: Forte Agent 2.0/32.640
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: bcarter.sentex.ca
X-Original-Trace: 24 Feb 2004 15:33:13 -0800, bcarter.sentex.ca
Lines: 41
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 24 Feb 2004 15:32:26 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 24 Feb 2004 15:32:59 -0800
X-Trace: forums-1-dub 1077665579 10.22.108.75 (24 Feb 2004 15:32:59 -0800)
X-Original-Trace: 24 Feb 2004 15:32:59 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2626
Article PK: 6100

DATEFORMAT and STRING are what you want...

BEGIN
DECLARE @d1 DATE;
DECLARE @d2 DATE;
SET @d1 = '2004-2-22';
SET @d2 = '2004-2-28';
SELECT STRING ( DATEFORMAT ( @d1, 'Mm/Dd/yyyy' ),
' To ',
DATEFORMAT ( @d2, 'Mm/Dd/yyyy' ) );
END;

Note that the mixed-case Mm suppresses zero padding, whereas same-case
mm or MM pads with a zero.

Breck

On 24 Feb 2004 15:10:00 -0800, "Chandresh Patel" <bapashree@yahoo.com>

wrote:

>Hi,
>
>Sybase Anywhere 9.0.0.1108
>
>I have two date variable in my procedure and i want to create one string and
>insert in to database varchar(30) field.
>
>I want string like : "2/22/2004 To 2/28/2004" and this value i want to
>insert in table as a string.
>
>How do i do this.
>
>Thanks in Advance.
>

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
bcarter@risingroad.com
Mobile and Distributed Enterprise Database Applications
www.risingroad.com


Chandresh Patel Posted on 2004-02-25 05:16:11.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
References: <403bd9d7$1@forums-2-dub> <dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com>
Subject: Re: How to convert date to string
Lines: 69
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: ac8285a6.ipt.aol.com
Message-ID: <403c2fa9@forums-2-dub>
X-Original-Trace: 24 Feb 2004 21:16:25 -0800, ac8285a6.ipt.aol.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 24 Feb 2004 21:15:37 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 24 Feb 2004 21:16:11 -0800
X-Trace: forums-1-dub 1077686171 10.22.108.75 (24 Feb 2004 21:16:11 -0800)
X-Original-Trace: 24 Feb 2004 21:16:11 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2628
Article PK: 6103

Thank you.

Perfact what i need.

Tell me if I have two DATE variable and want to make Start year date and
second is End year date in procedure.

Year means dynamic (based on system clock)

BEGIN
DECLARE @d1 DATE;
DECLARE @d2 DATE;
SET @d1 = Here how do i set start year
SET @d2 = Here how do i set end year
END;

because I don't know in program which year is current.

Thanks in Advance.

"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
message news:dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com...
> DATEFORMAT and STRING are what you want...
>
> BEGIN
> DECLARE @d1 DATE;
> DECLARE @d2 DATE;
> SET @d1 = '2004-2-22';
> SET @d2 = '2004-2-28';
> SELECT STRING ( DATEFORMAT ( @d1, 'Mm/Dd/yyyy' ),
> ' To ',
> DATEFORMAT ( @d2, 'Mm/Dd/yyyy' ) );
> END;
>
> Note that the mixed-case Mm suppresses zero padding, whereas same-case
> mm or MM pads with a zero.
>
> Breck
>
> On 24 Feb 2004 15:10:00 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> wrote:
>
> >Hi,
> >
> >Sybase Anywhere 9.0.0.1108
> >
> >I have two date variable in my procedure and i want to create one string
and
> >insert in to database varchar(30) field.
> >
> >I want string like : "2/22/2004 To 2/28/2004" and this value i want to
> >insert in table as a string.
> >
> >How do i do this.
> >
> >Thanks in Advance.
> >
>
> --
> SQL Anywhere Studio 9 Developer's Guide
> Buy the book:
http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> bcarter@risingroad.com
> Mobile and Distributed Enterprise Database Applications
> www.risingroad.com


Chandresh Patel Posted on 2004-02-25 05:31:01.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
References: <403bd9d7$1@forums-2-dub> <dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com>
Subject: Re: How to convert date to string
Lines: 56
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: ac8285a6.ipt.aol.com
Message-ID: <403c3323@forums-2-dub>
X-Original-Trace: 24 Feb 2004 21:31:15 -0800, ac8285a6.ipt.aol.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 24 Feb 2004 21:30:26 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 24 Feb 2004 21:31:01 -0800
X-Trace: forums-1-dub 1077687061 10.22.108.75 (24 Feb 2004 21:31:01 -0800)
X-Original-Trace: 24 Feb 2004 21:31:01 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2630
Article PK: 6104

to convert for start year I try this but it didn't work


SET eDate = DATE(YEAR(now())+'-12-31');
SET sDate = DATE(YEAR(now())+'-1-1');

"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
message news:dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com...
> DATEFORMAT and STRING are what you want...
>
> BEGIN
> DECLARE @d1 DATE;
> DECLARE @d2 DATE;
> SET @d1 = '2004-2-22';
> SET @d2 = '2004-2-28';
> SELECT STRING ( DATEFORMAT ( @d1, 'Mm/Dd/yyyy' ),
> ' To ',
> DATEFORMAT ( @d2, 'Mm/Dd/yyyy' ) );
> END;
>
> Note that the mixed-case Mm suppresses zero padding, whereas same-case
> mm or MM pads with a zero.
>
> Breck
>
> On 24 Feb 2004 15:10:00 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> wrote:
>
> >Hi,
> >
> >Sybase Anywhere 9.0.0.1108
> >
> >I have two date variable in my procedure and i want to create one string
and
> >insert in to database varchar(30) field.
> >
> >I want string like : "2/22/2004 To 2/28/2004" and this value i want to
> >insert in table as a string.
> >
> >How do i do this.
> >
> >Thanks in Advance.
> >
>
> --
> SQL Anywhere Studio 9 Developer's Guide
> Buy the book:
http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> bcarter@risingroad.com
> Mobile and Distributed Enterprise Database Applications
> www.risingroad.com


Breck Carter [TeamSybase] Posted on 2004-02-25 11:04:39.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: How to convert date to string
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <030p30dqr8c60d6g06rptgfdf0dsbl166i@4ax.com>
References: <403bd9d7$1@forums-2-dub> <dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com> <403c3323@forums-2-dub>
X-Newsreader: Forte Agent 2.0/32.640
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: bcarter.sentex.ca
X-Original-NNTP-Posting-Host: bcarter.sentex.ca
Date: 25 Feb 2004 03:04:39 -0800
X-Trace: forums-1-dub 1077707079 64.7.134.118 (25 Feb 2004 03:04:39 -0800)
X-Original-Trace: 25 Feb 2004 03:04:39 -0800, bcarter.sentex.ca
Lines: 82
X-Authenticated-User: TeamPS
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2631
Article PK: 6105

BEGIN
DECLARE @d1 DATE;
DECLARE @d2 DATE;
SET @d1 = STRING ( YEAR ( CURRENT DATE ), '-1-1' );
SET @d2 = STRING ( YEAR ( CURRENT DATE ), '-12-31' );
SELECT @d1, @d2;
END;

You can find out what data type a function returns by using EXPRTYPE;
for example,

SELECT EXPRTYPE ( 'SELECT YEAR ( CURRENT DATE )', 1 )

displays 'smallint'.

Breck

On 24 Feb 2004 21:31:01 -0800, "Chandresh Patel" <bapashree@yahoo.com>

wrote:

>to convert for start year I try this but it didn't work
>
>
>SET eDate = DATE(YEAR(now())+'-12-31');
>SET sDate = DATE(YEAR(now())+'-1-1');
>
>
>
>
>"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
>message news:dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com...
>> DATEFORMAT and STRING are what you want...
>>
>> BEGIN
>> DECLARE @d1 DATE;
>> DECLARE @d2 DATE;
>> SET @d1 = '2004-2-22';
>> SET @d2 = '2004-2-28';
>> SELECT STRING ( DATEFORMAT ( @d1, 'Mm/Dd/yyyy' ),
>> ' To ',
>> DATEFORMAT ( @d2, 'Mm/Dd/yyyy' ) );
>> END;
>>
>> Note that the mixed-case Mm suppresses zero padding, whereas same-case
>> mm or MM pads with a zero.
>>
>> Breck
>>
>> On 24 Feb 2004 15:10:00 -0800, "Chandresh Patel" <bapashree@yahoo.com>
>> wrote:
>>
>> >Hi,
>> >
>> >Sybase Anywhere 9.0.0.1108
>> >
>> >I have two date variable in my procedure and i want to create one string
>and
>> >insert in to database varchar(30) field.
>> >
>> >I want string like : "2/22/2004 To 2/28/2004" and this value i want to
>> >insert in table as a string.
>> >
>> >How do i do this.
>> >
>> >Thanks in Advance.
>> >
>>
>> --
>> SQL Anywhere Studio 9 Developer's Guide
>> Buy the book:
>http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
>> bcarter@risingroad.com
>> Mobile and Distributed Enterprise Database Applications
>> www.risingroad.com
>

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
bcarter@risingroad.com
Mobile and Distributed Enterprise Database Applications
www.risingroad.com


Chandresh Patel Posted on 2004-02-25 16:16:22.0Z
From: "Chandresh Patel" <bapashree@yahoo.com>
Newsgroups: ianywhere.public.general
References: <403bd9d7$1@forums-2-dub> <dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com> <403c3323@forums-2-dub> <030p30dqr8c60d6g06rptgfdf0dsbl166i@4ax.com>
Subject: Re: How to convert date to string
Lines: 91
Organization: Shreeji Smart Solution
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: acd0e372.ipt.aol.com
Message-ID: <403cca65@forums-2-dub>
X-Original-Trace: 25 Feb 2004 08:16:37 -0800, acd0e372.ipt.aol.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 25 Feb 2004 08:15:45 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 25 Feb 2004 08:16:22 -0800
X-Trace: forums-1-dub 1077725782 10.22.108.75 (25 Feb 2004 08:16:22 -0800)
X-Original-Trace: 25 Feb 2004 08:16:22 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:2632
Article PK: 6106

Thank you very much.

"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
message news:030p30dqr8c60d6g06rptgfdf0dsbl166i@4ax.com...
> BEGIN
> DECLARE @d1 DATE;
> DECLARE @d2 DATE;
> SET @d1 = STRING ( YEAR ( CURRENT DATE ), '-1-1' );
> SET @d2 = STRING ( YEAR ( CURRENT DATE ), '-12-31' );
> SELECT @d1, @d2;
> END;
>
> You can find out what data type a function returns by using EXPRTYPE;
> for example,
>
> SELECT EXPRTYPE ( 'SELECT YEAR ( CURRENT DATE )', 1 )
>
> displays 'smallint'.
>
> Breck
>
> On 24 Feb 2004 21:31:01 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> wrote:
>
> >to convert for start year I try this but it didn't work
> >
> >
> >SET eDate = DATE(YEAR(now())+'-12-31');
> >SET sDate = DATE(YEAR(now())+'-1-1');
> >
> >
> >
> >
> >"Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com> wrote in
> >message news:dhnn30he1goe4bluumuqokacbhc7p3otn3@4ax.com...
> >> DATEFORMAT and STRING are what you want...
> >>
> >> BEGIN
> >> DECLARE @d1 DATE;
> >> DECLARE @d2 DATE;
> >> SET @d1 = '2004-2-22';
> >> SET @d2 = '2004-2-28';
> >> SELECT STRING ( DATEFORMAT ( @d1, 'Mm/Dd/yyyy' ),
> >> ' To ',
> >> DATEFORMAT ( @d2, 'Mm/Dd/yyyy' ) );
> >> END;
> >>
> >> Note that the mixed-case Mm suppresses zero padding, whereas same-case
> >> mm or MM pads with a zero.
> >>
> >> Breck
> >>
> >> On 24 Feb 2004 15:10:00 -0800, "Chandresh Patel" <bapashree@yahoo.com>
> >> wrote:
> >>
> >> >Hi,
> >> >
> >> >Sybase Anywhere 9.0.0.1108
> >> >
> >> >I have two date variable in my procedure and i want to create one
string
> >and
> >> >insert in to database varchar(30) field.
> >> >
> >> >I want string like : "2/22/2004 To 2/28/2004" and this value i want to
> >> >insert in table as a string.
> >> >
> >> >How do i do this.
> >> >
> >> >Thanks in Advance.
> >> >
> >>
> >> --
> >> SQL Anywhere Studio 9 Developer's Guide
> >> Buy the book:
> >http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> >> bcarter@risingroad.com
> >> Mobile and Distributed Enterprise Database Applications
> >> www.risingroad.com
> >
>
> --
> SQL Anywhere Studio 9 Developer's Guide
> Buy the book:
http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
> bcarter@risingroad.com
> Mobile and Distributed Enterprise Database Applications
> www.risingroad.com