Any simple method to check date format (YYDDD)?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Any simple method to check date format (YYDDD)?
# 1  
Old 01-02-2008
Question Any simple method to check date format (YYDDD)?

Hi Guru's,

Are there any simple method to check the date format which is in "YYDDD"
(ex: 08002 for 02-Jan-2008)?

Eventhough this can be implemented in several way's, I need the simpler one. Any idea would be much appreciated.

Thanks in advance,
Mysore Ganapati
# 2  
Old 01-02-2008
Quote:
Originally Posted by ganapati
Hi Guru's,

Are there any simple method to check the date format which is in "YYDDD"
(ex: 08002 for 02-Jan-2008)?

Eventhough this can be implemented in several way's, I need the simpler one. Any idea would be much appreciated.

Thanks in advance,
Mysore Ganapati
08366 will be greater than 08100 which will be greater than 08001.

You can use a simple -gt construct.

Code:
if [[ $ldate -gt $rdate ]] ; then
  echo "$ldate is greater is than $rdate"
fi ;

# 3  
Old 01-02-2008
Error

Sorry Vino but thanks,

My question is for the format of the date (YYDDD). i.e,
  1. YYDDD field should not be blank
  2. YY should be only from 00-99, not any other charecters and come first before DDD.
  3. DDD should be from 001-365 for normal years and 001-366 for leap years. This should come after YY

Iam looking for simpler code to accomplish this.

Thanks again,
Ganapati
# 4  
Old 01-02-2008
Quote:
Originally Posted by ganapati
Sorry Vino but thanks,

My question is for the format of the date (YYDDD). i.e,
  1. YYDDD field should not be blank
  2. YY should be only from 00-99, not any other charecters and come first before DDD.
  3. DDD should be from 001-365 for normal years and 001-366 for leap years. This should come after YY

Iam looking for simpler code to accomplish this.

Thanks again,
Ganapati
Ah, I misread your question. Smilie
You will have to split the input into fields of 2 and 3. Compare the first against the limits you have in mind. And likewise with the other field. Looking at your requirements, why dont you use the information you asked for in the other thread ? https://www.unix.com/unix-dummies-que...er-number.html
# 5  
Old 01-03-2008
Thanks, but again some problem are there with this approach:
Any way thanks for the hint...

With respect and regards, Smilie
Mysore Ganapati
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to check date format DDMMYYYY

Record: Record1|Record2|Record3|Record4|Record5|DATE1|DATE2 Need to Check DATE1 & DATE2 is in DDMMYYYY format in a file. records which not meet the date format DDMMYYYY extract to other file. (1 Reply)
Discussion started by: vivekn
1 Replies

2. Shell Programming and Scripting

Check Date Format And Email Out

Hello All, I have a requirement where i need to get the EXTRACT_DATE from a file and check if the date is of valid format or not and then mail it if it is not valid. Appreciate if you can help me with this. I did the following so far. awk '{for(i=1;i++<=NF;)if($i~/^EXTRACT_DATE/) print $i}'... (11 Replies)
Discussion started by: Ariean
11 Replies

3. Shell Programming and Scripting

How to check if date format is correct?

Hi! how do i know if the input is the same as the required date format? the date should be dd/mm/YYYY ex. 2/3/2012 or 15/11/2012 all the following conditions must return an error: *input of string *day is > 31 or < 1 *month is > 12 or < 1 *year is < 2013 suppose the date format is stored... (1 Reply)
Discussion started by: angilulu
1 Replies

4. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

5. Shell Programming and Scripting

PERL : hhmiss - Date format check and replace

I have a filename, This can be any of any format, I want to check if the filename has hours,mins and seconds part. If it is present, i want to replace it with a " * " (star symbol) output needed: IMP: The time part can be in any pattern. How can this be done?:confused:... (3 Replies)
Discussion started by: irudayaraj
3 Replies

6. Shell Programming and Scripting

Need to check date format yyyymm

My source file having one date column. The formate of the date column is yyyymm. I need to validate whether all the rows are in same format in the given file. If it is not I have captured that records in a separate file. I am very new to Unix. I don't how to achieve this. Plz help me to achieve... (2 Replies)
Discussion started by: suresh01_apk
2 Replies

7. Shell Programming and Scripting

Check input date format?

how to check input date format. for example $input_date must be in format dd.mm.gg script is execute like this: bin/script1.sh 14.12.2009 script1.sh code: #!/bin/sh input_date=$1 CMD="/app/si/test/test.sh $input_date" echo "*****" $CMD (2 Replies)
Discussion started by: waso
2 Replies

8. Shell Programming and Scripting

20090620231013 to date format i am using substr, any simple way in perl?

Hi Everyone, $tmp="20090620231013"; $tmp = substr($tmp,0,8)." ".substr($tmp,8,2).":".substr($tmp,10,2).":".substr($tmp,12,2); So my output is: 20090620 23:10:13. I only can think substr is easy, any perl can do this just one line very simple efficient one? :eek: Thanks (3 Replies)
Discussion started by: jimmy_y
3 Replies

9. Shell Programming and Scripting

Check the format of Date

Hi, I have a date field in my input file. I just want to check if its in the format "DD-MM-YYYY". Is there any command which can achieve this? Thanks and Regards, Abhishek (2 Replies)
Discussion started by: AAA
2 Replies

10. Shell Programming and Scripting

Check for the correct date format in UNIx

Hi All, I am getting two input from User for Date from the command prompt when my script is executed . The date format i am taking is : DD-MM-YYYY so is there any method in Unix to validate the two input date. There might be many cases for these two date to be invalid.... (1 Reply)
Discussion started by: rawatds
1 Replies
Login or Register to Ask a Question