Sponsored Content
Full Discussion: date comparision
Operating Systems Solaris date comparision Post 302142442 by dave_nithis on Friday 26th of October 2007 07:35:29 AM
Old 10-26-2007
Data Compare two dates using shell scripting

a=2007-05-10 (YYYY-DD-MM Format)
b=2007-06-10

These are the two given dates and I need to compare.
(First It should split the dates into YYYY,dd,mm)

The script should first compare years(2007 here).If both are same or if "a" is lesser than "b"(ie.suppose year in "a" is 2006),it should print correct.If "a"(ie. suppose year in a is 2008) is greater than b,then it should print error.Similarly for the dates(05 and 06).

No need to check for the months(10).

Regards,
Dave Nithis.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

date comparision

Hello, I am trying to compare two dates which are in variables and i am not getting the correct result as expected. $first_date = '07/19/2007' $second_date='07/20/2007' Can you please suggest how to i check whether they are equal or not. if ($first_date -eq $second_date) condition is not... (3 Replies)
Discussion started by: kotasateesh
3 Replies

2. Shell Programming and Scripting

while - comparision

Hi, Please find the attached scriplet and suggest me to fix the bug in this. ----------------------------------- noofdirs=`ls *.tar | wc -l` if ; then let i=1 while ( $i <= $noofdirs ) ; do echo $i mkdir $i file1=`ls *.tar | head -1` mv $file1 $i i =... (2 Replies)
Discussion started by: sharif
2 Replies

3. Shell Programming and Scripting

Date Comparision in the File

Hi All, I have thefollowing files in the directory inbox/sat ras.sat.trn.20090103.001902.00004358 ras.sat.trn.20090612.001903.00005339 ras.sat.trn.20090723.001902.00004358 The above file contains the date of the file creation. We just need to write a ksh shell script to check the... (5 Replies)
Discussion started by: satheesh_color
5 Replies

4. Shell Programming and Scripting

Problem with Date Comparision

Hi, I have a file which has the date in the last line in the example pasted along with the rates of the countries. -- I want to compare the date in the last line of the file mentioned in the example below with the system date from Monday to Friday. -- If system date is equal to the date... (2 Replies)
Discussion started by: Raji_gadam
2 Replies

5. Shell Programming and Scripting

problem in date comparision

#!/bin/ksh var="2009-08-31 12:39:05 UTC" ddate=`echo $var|cut -d' ' -f1` y1=`echo $ddate|cut -d'-' -f1` m1=`echo $ddate|cut -d'-' -f2` d1=`echo $ddate|cut -d'-' -f3` filedate=$y1$m1$d1 currdate="20070814" if ]; then echo "$LINE -> $filedate LOWER THAN $currdate" ... (0 Replies)
Discussion started by: HemaV
0 Replies

6. Programming

Problem with date comparision in Pro*C

Hi, I have written the following Pro*C program to get the difference between 2 dates.But when I am printing the value of the date difference,it is always showing 0. #include<stdio.h> #include<sqlca.h> #include<oraca.h> void main() { EXEC SQL BEGIN DECLARE SECTION; int diff; ... (4 Replies)
Discussion started by: sureshbabuc
4 Replies

7. Shell Programming and Scripting

Date - String comparision

Hi, I am having difficulty to compare a string in a file against a date from a a table and print the latest date. Below are the values. String in File : 2009-12-02 00:37:51 Value Table : 2010-01-10-02.00.49.294758 I have to compare both the values ( Ignore the Microsecond in the table... (5 Replies)
Discussion started by: sam_78_nyc
5 Replies

8. Shell Programming and Scripting

Date Manipulation and Comparision

Hi All, I want to generate quarter dates using awk or anything, by giving a dates as input for example : start_date=2010-01-01 end_date=2010-05-31 output should be: start_date end_date qtr 2010-01-01 2010-03-31 1 2010-04-01 2010-05-31 2 Example 2:... (1 Reply)
Discussion started by: sol_nov
1 Replies

9. Shell Programming and Scripting

Date comparision in Unix

Hi All, I would need your help to compare dates in my script. Say if I have the dates in a file I need to comapre these dates with yesterday's date and the dates which are older than yesterday needs to be displayed. Example: 03/22/2012 03/24/2012 03/20/2012 03/21/2012 03/12/2012... (1 Reply)
Discussion started by: pdreddy34
1 Replies

10. Shell Programming and Scripting

Date command comparision with a different format

I have a script called " passwd_status " which gives the passwd-s status of my servers. the script output is like below password status for A: abc ks 10/05/115 1 30 ps password status for B: abc ks 09/25/115 1 30 ps password status for C: abc ks 10/10/115 1 30 ps Now , i want to... (1 Reply)
Discussion started by: charanarjun
1 Replies
CAL(1)							    BSD General Commands Manual 						    CAL(1)

NAME
cal -- displays a calendar SYNOPSIS
cal [-3hjry] [-A after] [-B before] [-d day-of-week] [-R reform-spec] [[month] year] DESCRIPTION
cal displays a simple calendar. If arguments are not specified, the current month is displayed. The options are as follows: -3 Same as ``-A 1 -B 1''. -A after Display after months after the specified month. -B before Display before months before the specified month. -d day-of-week Specifies the day of the week on which the calendar should start. Valid values are 0 through 6, presenting Sunday through Saturday, inclusively. The default output starts on Sundays. -h Highlight the current day, if present in the displayed calendar. If output is to a terminal, then the appropriate terminal sequences are used, otherwise overstriking is used. If more than one -h is used and output is to a terminal, the current date will be high- lighted in inverse video instead of bold. -j Display Julian dates (days one-based, numbered from January 1). -R reform-spec Selects an alternate Gregorian reform point from the default of September 3rd, 1752. The reform-spec can be selected by one of the built-in names (see NOTES for a list) or by a date of the form YYYY/MM/DD. The date and month may be omitted, provided that what is specified uniquely selects a given built-in reform point. If an exact date is specified, then that date is taken to be the first missing date of the Gregorian Reform to be applied. -r Display the month in which the Gregorian Reform adjustment was applied, if no other month or year information is given. If used in conjunction with -y, then the entire year is displayed. -y Display a calendar for the current year. If no parameters are specified, the current month's calendar is displayed. A single parameter specifies the year and optionally the month in ISO format: ``cal 2007-12'' Two parameters denote the month (1 - 12) and year. Note that the century must be included in the year. A year starts on Jan 1. NOTES
In the USA and Great Britain the Gregorian Reformation occurred in 1752. By this time, most countries had recognized the reformation (although a few did not recognize it until the 1900's.) Eleven days following September 2, 1752 were eliminated by the reformation, so the calendar for that month is a bit unusual. In view of the chaotic way the Gregorian calendar was adopted throughout the world in the years between 1582 and 1928 make sure to take into account the date of the Gregorian Reformation in your region if you are checking a calendar for a very old date. cal has a decent built-in list of Gregorian Reform dates and the names of the countries where the reform was adopted: Italy Oct. 5, 1582 Denmark Feb. 19, 1700 Spain Oct. 5, 1582 Great Britain Sep. 3, 1752 Portugal Oct. 5, 1582 Sweden Feb. 18, 1753 Poland Oct. 5, 1582 Finland Feb. 18, 1753 France Dec. 12, 1582 Japan Dec. 20, 1872 Luxembourg Dec. 22, 1582 China Nov. 7, 1911 Netherlands Dec. 22, 1582 Bulgaria Apr. 1, 1916 Bavaria Oct. 6, 1583 U.S.S.R. Feb. 1, 1918 Austria Jan. 7, 1584 Serbia Jan. 19, 1919 Switzerland Jan. 12, 1584 Romania Jan. 19, 1919 Hungary Oct. 22, 1587 Greece Mar. 10, 1924 Germany Feb. 19, 1700 Turkey Dec. 19, 1925 Norway Feb. 19, 1700 Egypt Sep. 18, 1928 The country known as Great Britain can also be referred to as England since that has less letters and no spaces in it. This is meant only as a measure of expediency, not as a possible slight to anyone involved. HISTORY
A cal command appeared in Version 6 AT&T UNIX. BSD
December 21, 2007 BSD
All times are GMT -4. The time now is 10:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy