How to create the first date when I have the month and year

anirbancse
Member Posts: 20
Hi!!!
I have one field(datatype=code) named Period. If it has value as 2016_01 then I need to get the First Date of January of that year i.e 01/01/2016, if it is 2015_08 then 01/08/2015, this way. How can I do that? any suggestion?
Thanks in advance..
I have one field(datatype=code) named Period. If it has value as 2016_01 then I need to get the First Date of January of that year i.e 01/01/2016, if it is 2015_08 then 01/08/2015, this way. How can I do that? any suggestion?
Thanks in advance..
0
Best Answer
-
Anirbancse,
Use this code
DateValue := '2018_12';
Year := COPYSTR(DateValue,1,4);
Month := COPYSTR(DateValue,6,7);
EVALUATE(NewMonth,Month);
EVALUATE(NewYear,Year);
NewDate := DMY2DATE(1,NewMonth,NewYear);
NewDate will have the desired result.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/5
Answers
-
Hey Anirbance,
The format of this 2016_01 will always be same OR it may change something like 01_2016 or it will always be in this format 2016_01?Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0 -
It will always be like that..2016_01,2016_02...2017_01 and so on..0
-
Hi Anirbancse,
Is it that solutuon you would like to have?
Datestr2:=CONVERTSTR(Datestr, '_', ',');
evaluate(dateVar,strsubstno('01/%2/%3',SELECTSTR(2, Datestr2),SELECTSTR(1, Datestr2));
you will have required date in dateVar.
Nav Upgrades and DEV outsourcing
Reports transformation to RDLC
List -1h , Complex List -3h, Document -4h (dev hours)
navisionupgrade.com0 -
another option :
evaluate(Year, copystr(datestr,1,4));
evaluate(Month, copystr(datestr,6,2));
Datevar := DMY2Date(1,month,year);
0 -
Anirbancse,
Use this code
DateValue := '2018_12';
Year := COPYSTR(DateValue,1,4);
Month := COPYSTR(DateValue,6,7);
EVALUATE(NewMonth,Month);
EVALUATE(NewYear,Year);
NewDate := DMY2DATE(1,NewMonth,NewYear);
NewDate will have the desired result.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/5 -
Hi all,
Thanks for your repiles.
@RockWithNAV : I got it working following your step. Thanks. My code is as followed and it is working fine.
IF RecABC.FINDFIRST THEN BEGIN
year := COPYSTR(RecABC."Invoicing Period",1,4);
month := COPYSTR(RecABC."Invoicing Period",6,7);
EVALUATE(DateFrom,'01'+'/'+month+'/'+year);
DateTo := CLOSINGDATE(DateFrom);
END
Invoicing Period = 2016_01,2016_02..this way..
o/p: DateFrom = 01/01/2016 and DateTo = 31/01/2016.
Thank you guys..0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions