on 09-04-2015 1:15 PM
Hi,
In CBTA
I initialized a variable(V_DATE) with current date using expression-
%=day(now)&"."&month(now)&"."&year(now)%
Then I want to add 1 to day,so I used the below expression-
%=DateAdd("d",1,$V_DATE$)%
But the DateAdd function is not working.
Can anyone tell me how to use variable(V_DATE) in DateAdd function.
Thanks in advance for your help
Hi Archana,
If your requirement is to have next day date, you can create one more variable as "V_NEXT_DATE' with expression
%=(day(now)+1)&"."&month(now)&"."&year(now)%
This will give tomorrows date always. Same you can do for next month if required.
This is easiest way but may fail if current date is 30/31st. If you want to make is more intelligent you need to write custom function.
Hope this helps you.
Regards,
Sachin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tom,
I already checked your blog. But if I use &Date then I have to change my system time format.
In order to make code flexible enough to run in any system without any pre-settings, I should use variables which will change dynamically.
Moreover,when I am using the same function for time its working fine as shown below but not working for date
%=DateAdd("n",-30,$V_TIME_STRT$)%
where V_TIME_STRT=%=Right("00"&Hour(Time),2)&":"&Right("00"&Minute(Time),2)&":"&Right("00"&Second(Time),2)%
Thanks & Regards,
Archana
Hi Tom
The provided code will work fine if we know the number of days/month/year to add/substract.
For e.g.- If we want last date of current month then
1. Store 1st day of next month in var
V_NEXT-->%="1."&month(DateAdd("m",1,now()))&"."&year(now)%
2. Substract 1 from V_NEXT to get last date of current month
%=DateAdd("d",-1,$V_NEXT$)%
But here the DateAdd() is not working
Do you have any alternative solution to this?
Thanks & Regards,
Archana
Hi Archana
Mm, haven't tried that before so I'm not sure that will work like that to use a variable in inline VB script. I would say write a custom function by using the custom library and pass on the variable as input and get the data back as output.
Again, I haven't tried it but that's what I would expect what should work out.
Best regards
Tom
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.