Date convert Help


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Date convert Help
# 1  
Old 05-20-2003
Question Date convert Help

Hi,
I need to convert a char date to the datetime format for a table in sybase. I don't know how to do it, can anyone help me on this ?

Thanks a lot !!!!


Smilie
# 2  
Old 05-20-2003
Perderabo's datecalc script may be what you are looking for.
If not, you might try searching for it in the forums.

Perderabo's datecalc script
# 3  
Old 05-20-2003
I'm just wondering, what does the date look like initially and what do you want it to look like afterwards? There are quite a few datetime formats, as listed here.
Code:
Sybase DateTime Formats
Format  # Format                     Description             Format #  Format
0         mon dd ccyy hh:mm xM       Default                 100       mon dd ccyy hh:mmxM 
1         mm/dd/yy                   USA                     101       mm/dd/ccyy 
2         yy.mm.dd                   ANSI                    102       ccyy.mm.dd 
3         dd/mm/yy                   English/French          103       dd/mm/ccyy 
4         dd.mm.yy                   German                  104       dd.mm.ccyy 
5         dd-mm-yy                                           105       dd-mm-ccyy 
6         dd mon yy                                          106       dd mon ccyy 
7         mon dd, yy                                         107       mon dd, ccyy 
8         hh:mm:ss                                           108       hh:mm:ss 
9         mon d ccyy hh:mm:ss:tttxM  default + milliseconds  109       mon d ccyy hh:mm:ss:tttxM 
10        mm-dd-yy                   USA                     110       mm-dd-ccyy 
11        yy/mm/dd                   Japan                   111       ccyy/mm/dd 
12        yymmdd                     ISO                     112       ccyymmdd 

Examples 
Format #  String                     Format #  String
0         Jan 3 2002 9:12AM          100       Jan 3 2002 9:12AM 
1         01/03/02                   101       01/03/2002 
2         02.01.03                   102       2002.01.03 
3         03/01/02                   103       03/01/2002 
4         03.01.02                   104       03.01.2002 
5         03-01-02                   105       03-01-2002 
6         03 Jan 02                  106       03 Jan 2002 
7         Jan 03, 02                 107       Jan 03, 2002 
8         09:12:34                   108       09:12:34 
9         Jan 3 2002 9:12:34:566AM   109       Jan 3 2002 9:12:34:566AM 
10        01-03-02                   110       01-03-2002 
11        02/01/03                   111       2002/01/03 
12        020103                     112       20020103


Last edited by oombera; 02-17-2004 at 03:42 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert date format

Hi guys I am looking to convert this kind of entry in a txt file 26/04/2008 to April 2008 Note : this is not using the date command , these are date entries in a file can i do this with sed ? Use code tags, thanks. (5 Replies)
Discussion started by: johnnybananas
5 Replies

2. Shell Programming and Scripting

Convert a date stored in a variable to epoch date

I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date #!/usr/bin/ksh set -x for s in server ; do ssh -T $s <<-EOF from_date="12-Jan-2015 12:02:09" to_date="24-Jan-2015 13:02:09" echo \$from_date echo... (7 Replies)
Discussion started by: raj48
7 Replies

3. Shell Programming and Scripting

Convert date arg to sql date

Doing a bcp load to sybase and need to convert datearg which comes in as 20130501 to 2013-05-01 which is the best way to do this (4 Replies)
Discussion started by: tasmac
4 Replies

4. UNIX for Dummies Questions & Answers

Unable to convert date into no. using date -d +%s syntax in ksh shell

hi friends, I m trying to write a script which compares to dates. for this i am converting dates into no using synatx as below v2=`date | awk '{print $2,$3,$4}'` v3=`date +%s -d "$v2"` this syntax is working in bash shell ,but fails in ksh shell. please suggest on this. (12 Replies)
Discussion started by: Jcpratap
12 Replies

5. Shell Programming and Scripting

Convert date

If I pass the value in the form YYYY/MM/DD(20100719) how to convert in the form 19\/Jul\/2010 (1 Reply)
Discussion started by: sandy1028
1 Replies

6. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

7. UNIX for Dummies Questions & Answers

Convert date format

Hi All, Need your help in converting a date format in ksh. I'm currently working on SUN os where my script is getting a date from a table. The result returns to ksh in this format: 17-JUL-08 How do i convert this string to a date format like yyyymmdd? I tried #!/bin/ksh d="17-JUL-08"... (5 Replies)
Discussion started by: agathaeleanor
5 Replies

8. Shell Programming and Scripting

Convert date from yymmdd to mm/dd/yy

Hi, I have a file where each record has a date field in yymmdd format. How can I convert it to a new file with the date changed to mm/dd/yy and a space before and after? Input file: 9S14BT080407000000 6S14YS080402000000 6S14CK080402000000 Output needed: 9S14BT 04/07/08 000000 6S14YS... (5 Replies)
Discussion started by: zmaster18
5 Replies

9. Shell Programming and Scripting

convert Julian date to calender date

Hi, I have script in unix which creates a julian date like 126 or 127 I want convert this julian date into calender date ex : input 127 output 07/may/2007 or 07/05/2007 or 07/05/07 rgds srikanth (6 Replies)
Discussion started by: srikanthus2002
6 Replies
Login or Register to Ask a Question