A Variable for Julian Dates...

Post comments and suggestions for RoboTask here
Post Reply
nkroger
Posts: 3
Joined: Mon May 23, 2005 9:25 am
Location: United States

A Variable for Julian Dates...

Post by nkroger »

A variable needs to be included so that you can use Julian Dates when the program is looking at file names....this would make my life much easier since 75% of the files I am sending and recieving include Julian Dates instead of a Month/Day/Year type date.
 
If anyone knows how to code a variable that will accepted Julian Dates that would be just as helpful, I havent been able to figure it out yet:(
Thanks for any help,
Nick
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

A Variable for Julian Dates...

Post by Oleg »

Date format depends of regional settings on your computer.
Has date been included into filename?
nkroger
Posts: 3
Joined: Mon May 23, 2005 9:25 am
Location: United States

A Variable for Julian Dates...

Post by nkroger »

an example file name would be loan.144.3437 where the 144 is the julian date for today tuesday may 24th.   The julian date is a number between 1 and 365 that begins with 1 on January 1st and incrememnts +1 each day. 
I haven't been able to find a working vairable structure to work with this type of date since the Windows Date and Time Properties doesn't have anything that remotely looks close to that format.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

A Variable for Julian Dates...

Post by Oleg »

What is 3437 in your example? 144 is a may 24, but what year?
Any date contain year. Or, may be, you not consider it?
nkroger
Posts: 3
Joined: Mon May 23, 2005 9:25 am
Location: United States

A Variable for Julian Dates...

Post by nkroger »

the 3437 is the customer number so we know what customer number the file is for.  No, no dates use the year in them that I am having problems with, all those files I have set up just fine....it is Julian Dates that I am having problems with.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

A Variable for Julian Dates...

Post by Oleg »

Hm… This method is valid only for non leap years.
I'll try to write sample task with basic script. By default year will be the current year.
If your number not contains year I need invent it. Have you another offers?
Last edited by Oleg on Wed May 25, 2005 1:53 am, edited 1 time in total.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

A Variable for Julian Dates...

Post by Oleg »

Try the task below. The task contains a BASIC script for transformation of Julian dates.
This script extracts Julian date from file name (variable C_File), converts it into date and assigns value as string to ConvertedDate variable in mm/dd format.

Save text of task into any file and use menu Task | Import to import into RoboTask.

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|418185034
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task265"
Hide=INTEGER|0
ID=INTEGER|2135619545
Name=STRING|"Convert julian dates"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action1\Params]
destvar=STRING|"C_FILE"
line0=STRING|"loan.144.3437"
line1=STRING|"loan.29.1128"
line2=STRING|"loan.35.6852"
line3=STRING|"loan.302.2759"
line4=STRING|"loan.30abc2.2759"
linecount=STRING|"5"
sourcetext=STRING|"1"

[Actions\Action2]
ActionID=STRING|"BASIC_SCRIPT"
Enabled=INTEGER|-1
Name=STRING|"Basic Script"
Params=FOLDER

[Actions\Action2\Params]
line00000=STRING|"'This script extracts Julian date from file name (variable C_File),"
line00001=STRING|"'converts it into date and assign value as string to ConvertedDate"
line00002=STRING|"'variable in mm/dd format"
line00004=STRING|"Sub Main"
line00005=STRING|" Dim s As String"
line00006=STRING|" Dim Julian As Integer"
line00007=STRING|" Dim d As Date"
line00009=STRING|" ' extract Julian date from file name"
line00010=STRING|" s = RoboTaskApp.ExpandText(""{ExtractFileExt({ExtractFileNameNoE xt({C_file})})}"")"
line00011=STRING|" 'MsgBox(s)"
line00013=STRING|" On Error Resume Next"
line00015=STRING|" ' convert string date to integer"
line00016=STRING|" Julian = CInt(s)"
line00017=STRING|" If Err Then"
line00018=STRING|"    Err.Clear"
line00019=STRING|"    Julian = 0"
line00020=STRING|" End If"
line00022=STRING|" If Julian >0 Then"
line00023=STRING|"    d = DateSerial(Year(Date),1,1)"
line00024=STRING|"    d = DateAdd(""d"",Julian-1,d)"
line00025=STRING|"    RoboTaskApp.SetUse rVariable(""ConvertedDate"", CStr(Month(d))+""/""+CStr(Day(d)))"
line00026=STRING|"    'MsgBox(CStr(Month (d))+""/""+CStr(Day(d)))"
line00027=STRING|" Else"
line00028=STRING|"    RoboTaskApp.SetUse rVariable(""ConvertedDate"", ""Invalid"")"
line00029=STRING|"    'MsgBox(""Invalid date"")"
line00030=STRING|" End If"
line00031=STRING|"End Sub"
linecount=STRING|"32"
source=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""file {c_file}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"file {c_file}"
msg1=STRING|"date is {ConvertedDate}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_REMOVE"
Enabled=INTEGER|-1
Name=STRING|"Remove variable ""C_FILE"""
Params=FOLDER

[Actions\Action5\Params]
varname=STRING|"C_FILE"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_REMOVE"
Enabled=INTEGER|-1
Name=STRING|"Remove variable ""CONVERTEDDATE"""
Params=FOLDER

[Actions\Action6\Params]
varname=STRING|"CONVERTEDDATE"
ahunkins
Posts: 24
Joined: Wed Dec 15, 2004 7:37 am

A Variable for Julian Dates...

Post by ahunkins »

Would it work to go the other way?  You can create a BASIC evaluation such as:
datediff("d","1/1/05","5/24/05") + 1
or
datediff("d","1/1/05",now()) + 1
You could use the resulting value to test in your filename.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

A Variable for Julian Dates...

Post by Oleg »

Do you want to convert real date to Julian format?
Post Reply