How to manipulate date?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to manipulate date?
# 1  
Old 04-04-2005
How to manipulate date?

Hi
can u pls help me out with this as
i am relatively new to unix.

I need to use 4 different types of dates in my shell script
* first day of the last(previous) month
* last day of the last(previous) month
* first day of the current month
* (sysdate-1) yesterday's date for the current month.
in dd/mm/yyyy HH24:MI:SS format..

I need to use them in my shell script
I need to pass the above date variables to a sql script..

thnks in advance..
# 2  
Old 04-04-2005
Please see link
# 3  
Old 04-04-2005
Hi
I don't want to use a function...

thnks a lot..
# 4  
Old 04-05-2005
Why not?

Please have a look at the link encrypted posted - there are many date manipulation techniques presented there.

Also; it might be worth posting your flavour of UNIX (uname -a), and which shell you're using (echo $SHELL; echo $0) so we can deduce what will be applicable to you - for example, using a system with GNU date installed gives the option of using the flexible -d option to date.

Cheers
ZB
# 5  
Old 04-06-2005
Hi ZB,
I am using ksh...and i have checked the encrypted link...there are several functions used..which I don't want to use..

$ uname -a
SunOS crddbdevl 5.6 Generic_105181-39 sun4u sparc SUNW,Ultra-Enterprise

$ date
Wed Apr 6 03:19:46 EDT 2005

and its ksh for sure....
# 6  
Old 04-06-2005
How do you think that you are going to be able to grab the time and date and manipulate it without calling unix functions. This must be a school assignment, that is the only reason that I can see that you wouldn't want to use already written functions.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A better way to manipulate text

Good morning everyone, I'm currently trying to convert an environment variable into a string and then attach it at the end of a command and launch it. I have the following right now, but it's very ugly: AMI_TAGS="env=test,country=XX,city=blah,galaxy=blahblah" aws ec2 create-tags... (8 Replies)
Discussion started by: da1
8 Replies

2. Shell Programming and Scripting

Manipulate a CSV File

Hello, How do i manipulate .csv file to this format? Thank you very much. Source: john,5 marco,7 john,4 paul,3 marco,8 Output: john,9 marco,15 (5 Replies)
Discussion started by: tara123
5 Replies

3. Shell Programming and Scripting

Need help to manipulate data using script

Hi i want to manipulate my data to convert row to column name 600 Slno vlan 1 600 2 609 3 700 name 700 Slno vlan 1 600 2 609 3 700 (8 Replies)
Discussion started by: nith_anandan
8 Replies

4. Shell Programming and Scripting

Manipulate file

Hi Guys, I have a file that lists patches along with other information. The patches are listed in two different formats. One format lists the latest patch, date , installed patch Latest Patch Date IN 148412-02 13-Sep-2012 -- X X SunOS 5.10: nss_dns patch 126206-10 ... (5 Replies)
Discussion started by: Tornado
5 Replies

5. Solaris

How to Manipulate Date based on number of days?

I have script where in i issue a command to get back 6 month earlier date. below command works on all linux distribution. # date +%Y-%m-%d --date="2012-03-31 - 183 days ago" 2011-09-30 Is there any solaris equivalent command to do the same? (1 Reply)
Discussion started by: pinga123
1 Replies

6. AIX

How to manipulate date format?

Hi, I need to convert the below string in 'yyyymmdd' format. e.g., 24 June 2011 -> 20110624 Please help !! (4 Replies)
Discussion started by: ruby
4 Replies

7. Shell Programming and Scripting

[bash] Manipulate dir name

Hi as output i get a directory (i don't know its name) with many files inside. Now i need to find the directory name and change it as i need. I can found a directory name with this command: find -maxdepth 1 -type d | grep out Now i'd like to assign it to a variable and change it. ... (4 Replies)
Discussion started by: Dedalus
4 Replies

8. Shell Programming and Scripting

manipulate postscript via sed

dear all, on solaris10 for x86 i am trying to modify the creation date of a postscript file with sed in a csh script. sed is driving me crazy though...i think due to the spaces in the string i am trying to substitute?? part of the postscript file: %!PS-Adobe-3.0... (3 Replies)
Discussion started by: lada niva
3 Replies

9. Shell Programming and Scripting

Manipulate files

Hi everybody: I have a problem. I have a output files which have this pattern: number1 --space block1a - 7rows/10columns/65elements --space block1b - 7rows/10columns/65elements --space block1c - 7rows/10columns/65elements --space number2 --space block2a - 7rows/10columns/65elements... (0 Replies)
Discussion started by: tonet
0 Replies

10. Shell Programming and Scripting

How to manipulate the output ???

In an operation, I have output like 22562K I want to manipulate this and want to perform some mathematical operations on that, any idea how can I get the digit no? (2 Replies)
Discussion started by: csaha
2 Replies
Login or Register to Ask a Question