03-05-2002
validating dates
This is what I have to check date entries in an interactive script with the end users... I use this to build control cards for a reporting utility supplied by a software vendor.
I also want to check to make sure its a valid day based on the month (ie 30days has sept, april, june and Nov..)... whats the best way to go that deep?
I'm working in digital unix ksh.
thanks!
while :; do
echo "Enter starting invoice date (CCYYMMDD or Quit): \c"
read DATE1
CENT1=`echo $DATE1 | cut -c1,2`
YR1=`echo $DATE1 | cut -c3,4`
MO1=`echo $DATE1 | cut -c5,6`
DD1=`echo $DATE1 | cut -c7,8`
case "$CENT1" in
19 | 20 ) ;;
* ) echo "Invalid Century, please re-enter entire date. \n" ;;
esac
case "$MO1" in
01|02|03|04|05|06|07|08|09|10|11|12 ) ;;
* ) echo "Invalid Month, please re-enter entire date. \n" ;;
esac
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi there,
I'm trying to validate my $1 and $2 before I use them in the sqlplus update, I think I have the validation rules set correctly??? however when I test my script, it jumps straight into the sql. It doesn't seem to validate the vars....even when I know they are incorrect.
if ; then
... (6 Replies)
Discussion started by: nhatch
6 Replies
2. Shell Programming and Scripting
Hello friends,
I am looking for a script or method that can display all the dates between any 2 given dates.
Input:
Date 1
290109
Date 2
010209
Output:
300109
310109
Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies
3. Programming
Don't know if it is important: Debian Linux / MySQL 5.1
I have a table:
media_id int(8)
group_id int(8)
type_id int(8)
expiration date
start date
cust_id int(8)
num_runs int(8)
preferred_time int(8)
edit_date timestamp ON UPDATE CURRENT_TIMESTAMP
id... (0 Replies)
Discussion started by: vertical98
0 Replies
4. Emergency UNIX and Linux Support
Hi guys,
For my wiki site I need to fix 1400 pages that use the wrong date format, most pages (not all) use eg. 1988]] I need to change that to (1988)]]
The date range goes back to 1400 so I guess I need to do the following
ssh into my server,
dump mysql database
vi .sql dump
search... (20 Replies)
Discussion started by: lawstudent
20 Replies
5. Shell Programming and Scripting
HI,
I am trying to write a validation script as below
awk '($1=="ABC"&&$2="XYZ" ,then check the value in $8,$10 these columns should not be null.
so their should be some corresponding value n the $8 and $10 column,if their is no value the script has to give error saying that at a... (2 Replies)
Discussion started by: gaur.deepti
2 Replies
6. UNIX for Dummies Questions & Answers
Hi All,
I am trying to print the dates that falls between 2 date variables into a file. Here is the example.
$BUS_DATE =20120616
$SUB_DATE=20120613
Output to file abc.txt should be : 20120613,20120614,120120615,20120616
Can you pls help me accomplish this in LINUX.
Thanks... (5 Replies)
Discussion started by: dsfreddie
5 Replies
7. Shell Programming and Scripting
HI,
i have row like this
HHH100037440313438961000201001012012073110220002 N
in this i have 2 dates in pos 25-32 and 33-40 , so based upon the se two dates , i need to generated records between these two values
so in the above record 20100101 and 20120731
need to genearte rows like this... (4 Replies)
Discussion started by: sathishsr
4 Replies
8. UNIX for Advanced & Expert Users
Hi Am Using Unix Ksh ...
I have a Table called date
select * from date ;
Date
01/02/2013
06/02/2013
I need the output as
Missing Date
01/02/2013
02/02/2013
03/02/2013
04/02/2013
05/02/2013
06/02/2013 (2 Replies)
Discussion started by: Venkatesh1
2 Replies
9. Shell Programming and Scripting
Hello All,
I have the following file. The first column is Type. Always the file will have one H and one T type in between all D type reocrds.
Need todo some validations.
H|ABCD
D|TAB N0003107809CD2013-11-14|RYAN|FRY|7 DR|RICHMOND HILL|GA|32431|X|C95|000009999|000000001|TAB||C0001
D|TAB... (3 Replies)
Discussion started by: karumudi7
3 Replies
10. Shell Programming and Scripting
Hi All,
I have 2 dates in mm/dd format.
sdate=10/01 (October 01)
edate=10/10 (October 10)
I need the dates in between these 2 dates like below.
10/01
10/02
10/03
10/04
10/05
10/06
10/07
10/08 (1 Reply)
Discussion started by: jayadanabalan
1 Replies
LEARN ABOUT PHP
datetime.settime
DATETIME.SETTIME(3) 1 DATETIME.SETTIME(3)
DateTime::setTime - Sets the time
Object oriented style
SYNOPSIS
public DateTime DateTime::setTime (int $hour, int $minute, [int $second])
DESCRIPTION
Procedural style
DateTime date_time_set (DateTime $object, int $hour, int $minute, [int $second])
Resets the current time of the DateTime object to a different time.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $hour
- Hour of the time.
o $minute
- Minute of the time.
o $second
- Second of the time.
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | Changed the return value on success from NULL to |
| | DateTime. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
DateTime.setTime(3) example
Object oriented style
<?php
$date = new DateTime('2001-01-01');
$date->setTime(14, 55);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(14, 55, 24);
echo $date->format('Y-m-d H:i:s') . "
";
?>
Procedural style
<?php
$date = date_create('2001-01-01');
date_time_set($date, 14, 55);
echo date_format($date, 'Y-m-d H:i:s') . "
";
date_time_set($date, 14, 55, 24);
echo date_format($date, 'Y-m-d H:i:s') . "
";
?>
The above examples will output something similar to:
2001-01-01 14:55:00
2001-01-01 14:55:24
Example #2
Values exceeding ranges are added to their parent values
<?php
$date = new DateTime('2001-01-01');
$date->setTime(14, 55, 24);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(14, 55, 65);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(14, 65, 24);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(25, 55, 24);
echo $date->format('Y-m-d H:i:s') . "
";
?>
The above example will output:
2001-01-01 14:55:24
2001-01-01 14:56:05
2001-01-01 15:05:24
2001-01-02 01:55:24
SEE ALSO
DateTime.setDate(3), DateTime.setISODate(3).
PHP Documentation Group DATETIME.SETTIME(3)