![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sysdate -1 in unix | kskywr | UNIX for Dummies Questions & Answers | 1 | 04-12-2007 09:53 AM |
| sysdate -p -f%d/%m/%Y | abu_hassan | UNIX for Dummies Questions & Answers | 1 | 02-11-2007 08:26 AM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | HP-UX | 1 | 10-16-2006 01:16 PM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | Shell Programming and Scripting | 0 | 09-19-2006 06:44 PM |
| How to get sysdate -1 | gopskrish | UNIX for Dummies Questions & Answers | 2 | 06-23-2005 03:38 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Getting sysdate - 2 by an unix command
How can I get an equivalent in unix for the following Oracle SQL command:
select sysdate - 2 from dual; Thanks José
__________________
José |
| Forum Sponsor | ||
|
|
|
||||
|
Except if you run it on the 1st, then 1-2 = -1. Oops.
A portable solution is to convert the current date to a julian value, subtract 2 and then convert back to a gregorian value. A script to convert to/from julian date is here: http://droflet.net/julian.txt Last edited by PxT; 08-28-2001 at 11:49 AM. |
|
|||
|
this login does not work with number greater than the days passed in the going month.
plz try this script it will fail . #!/usr/bin/sh echo "Plz enter the number of diff required" read _diff _day=`date +%d` _month=`date +%m` _year=`date +%y` newday=`expr $_day - $_diff` echo "Two days ago was $_month/$newday/$_year " |
|
||||
|
Yeah, that is the shortcoming that PxT pointed out in my script also. I like his idea better of converting to julian date, subtracting the number you need, then converting back to regular date. Please check out his script - it's much better, and is less likely to contain the simple errors I have included (as features, of course) in mine. |
||||
| Google The UNIX and Linux Forums |