ADATE

=ADATE(a,t,cl)

a
array
t
type, string, only one of this values "f", "e", "m" , "y" , "q" , "od" , "om" ,"oq"
cl
integer, column index of dates. if ignored or 1, first column will be changed. if more columns have dates format and needs to be replaced we have to use nested ADATE(ADATE(a,"m",),"y",4)

replaces only the dates column values of an array with other data types formats, leaving the rest of the array intact

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
860
Office Version
  1. 365
Platform
  1. Windows
ADATE replaces only the dates column values of an array with other data types formats, leaving the rest of the array intact.
t (type) argument options : "f" , first day of month ; "e" , end of month ; "m" , month ; "y" , year ; "q" , quarter ; "od" , only date value ; "om" , only month ; "oq" , only quarter
Other functions on minisheet ADVFLT , ARRANGE , ACOMBINE
Excel Formula:
=LAMBDA(a,t,cl,
    LET(c,MAX(1,cl),l,COLUMNS(a),sl,SEQUENCE(,l),
       d,DAY(a),m,MONTH(a),y,YEAR(a),r,y&"-",
       x,SWITCH(t,"m",TEXT(a,"yyy-mm-mmm"),"y",TEXT(a,"yyy"),"e",EOMONTH(+a,0),"f",EOMONTH(+a,-1)+1,"q",IFS(m<=3,r&"Q1",
       m<=6,r&"Q2",m<=9,r&"Q3",m<=12,r&"Q4"),"od",d,"om",TEXT(a,"mm-mmm"),"oq",IFS(m<=3,"Q1",m<=6,"Q2",m<=9,"Q3",m<=12,"Q4")),
       IF(OR(t={"od","m","y","q","e","f","om","oq"}),IF(sl=c,x,a),"check data")
    )
)
LAMBDA 7.0.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJ
1=RANDARRAY(20,,"1-01-19",TODAY(),1)sample 2filter btw Mar-2019 and Mar 2020
2rnd dates generatorsample 1=ADATE(C3:E22,"f",)=ADATE(C3:E22,"e",)=ADATE(C3:E22,"m",)=ADATE(C3:E22,"y",)=ARRANGE(C3:E22,{3,1})=ADATE(W3#,"m",2)=ADVFLT(AA3#,{2,2},{">=2019-03-mar","<=2020-03-mar"},,)
330-04-2005-05-19Bx01-05-19Bx31-05-19Bx2019-05-MayBx2019Bxx43590Bx2019-05-MayBx2019-05-MayB
401-09-1927-02-21Ax01-02-21Ax28-02-21Ax2021-02-FebAx2021Axx44254Ax2021-02-FebAy2019-12-DecA
512-03-2107-03-21By01-03-21By31-03-21By2021-03-MarBy2021Byy44262By2021-03-MarBx2019-05-MayB
630-04-2119-12-19Ay01-12-19Ay31-12-19Ay2019-12-DecAy2019Ayy43818Ay2019-12-DecAy2020-02-FebA
721-01-2005-08-20By01-08-20By31-08-20By2020-08-AugBy2020Byy44048By2020-08-AugBy2020-02-FebA
820-07-2008-05-19Bx01-05-19Bx31-05-19Bx2019-05-MayBx2019Bxx43593Bx2019-05-MayBy2020-03-MarA
915-09-1906-02-20Ay01-02-20Ay29-02-20Ay2020-02-FebAy2020Ayy43867Ay2020-02-FebAx2019-06-JunA
1021-06-2009-02-20Ay01-02-20Ay29-02-20Ay2020-02-FebAy2020Ayy43870Ay2020-02-FebA
1109-05-1909-01-19Bx01-01-19Bx31-01-19Bx2019-01-JanBx2019Bxx43474Bx2019-01-JanBadvanced filter options are endless
1230-08-1924-11-20Ax01-11-20Ax30-11-20Ax2020-11-NovAx2020Axx44159Ax2020-11-NovAfilter all values except year 2020
1302-09-2028-04-20By01-04-20By30-04-20By2020-04-AprBy2020Byy43949By2020-04-AprB=ADVFLT(AA3#,,,{2,2},{"<=2019-12-dec",">2020-12-dec"})
1402-07-2001-04-21Ax01-04-21Ax30-04-21Ax2021-04-AprAx2021Axx44287Ax2021-04-AprAx2019-05-MayB
1502-02-2016-04-21Bx01-04-21Bx30-04-21Bx2021-04-AprBx2021Bxx44302Bx2021-04-AprBx2021-02-FebA
1621-05-1929-03-20Ay01-03-20Ay31-03-20Ay2020-03-MarAy2020Ayy43919Ay2020-03-MarAy2021-03-MarB
1724-02-1916-02-21Ay01-02-21Ay28-02-21Ay2021-02-FebAy2021Ayy44243Ay2021-02-FebAy2019-12-DecA
1806-01-1921-03-21Bx01-03-21Bx31-03-21Bx2021-03-MarBx2021Bxx44276Bx2021-03-MarBx2019-05-MayB
1930-08-2018-06-19Ax01-06-19Ax30-06-19Ax2019-06-JunAx2019Axx43634Ax2019-06-JunAx2019-01-JanB
2013-02-2023-04-20Ax01-04-20Ax30-04-20Ax2020-04-AprAx2020Axx43944Ax2020-04-AprAx2021-04-AprA
2121-04-2001-01-19By01-01-19By31-01-19By2019-01-JanBy2019Byy43466By2019-01-JanBx2021-04-AprB
2228-07-1908-10-20Ay01-10-20Ay31-10-20Ay2020-10-OctAy2020Ayy44112Ay2020-10-OctAy2021-02-FebA
23x2021-03-MarB
24=ADATE(C3:E22,"q",)=ADATE(C3:E22,"od",)=ADATE(C3:E22,"om",)=ADATE(C3:E22,"oq",)=ADATE(W3#,"oq",2)filter only Q1 or Q4 values all timex2019-06-JunA
25t (type) argumentdata typeformat2019-Q2Bx5Bx05-MayBxQ2BxxQ2B=ADVFLT(W25#,,,{2,2},{"q1","q4"})y2019-01-JanB
26ffirst of monthdate2021-Q1Ax27Ax02-FebAxQ1AxxQ1AxQ1A
27eend of monthdate2021-Q1By7By03-MarByQ1ByyQ1ByQ1B
28mmonthtextyyyy-mm-mmm2019-Q4Ay19Ay12-DecAyQ4AyyQ4AyQ4A
29yyearnumeric2020-Q3By5By08-AugByQ3ByyQ3ByQ1A
30qquartertextyyyy-Qn2019-Q2Bx8Bx05-MayBxQ2BxxQ2ByQ1A
31odonly datenumeric2020-Q1Ay6Ay02-FebAyQ1AyyQ1AxQ1B
32omonly monthtextdd-mmm2020-Q1Ay9Ay02-FebAyQ1AyyQ1AxQ4A
33oqonly quartertextQn2019-Q1Bx9Bx01-JanBxQ1BxxQ1ByQ1A
342020-Q4Ax24Ax11-NovAxQ4AxxQ4AyQ1A
35Note:ADVFLT criteria arguments should follow 2020-Q2By28By04-AprByQ2ByyQ2BxQ1B
36the t (type) argument format of ADATE(see table)2021-Q2Ax1Ax04-AprAxQ2AxxQ2AyQ1B
372021-Q2Bx16Bx04-AprBxQ2BxxQ2ByQ4A
38other functions on minisheet2020-Q1Ay29Ay03-MarAyQ1AyyQ1A
39ADVFLT2021-Q1Ay16Ay02-FebAyQ1AyyQ1A
40ACOMBINE2021-Q1Bx21Bx03-MarBxQ1BxxQ1Blist all possible combinations
41ARRANGE2019-Q2Ax18Ax06-JunAxQ2AxxQ2A=ACOMBINE(AA26#,{2,3,1})
422020-Q2Ax23Ax04-AprAxQ2AxxQ2AQ1Ax
432019-Q1By1By01-JanByQ1ByyQ1BQ1Ay
442020-Q4Ay8Ay10-OctAyQ4AyyQ4AQ1Bx
45Q1By
46Q4Ax
47Q4Ay
48Q4Bx
49Q4By
50
ADATE post
Cell Formulas
RangeFormula
A1A1=FORMULATEXT(A3)
G2,K2,O2,AA41,AA25,G24,K24,O24,S24,W24,AF13,S2,W2,AA2,AF2G2=FORMULATEXT(G3)
A3:A22A3=RANDARRAY(20,,"1-01-19",TODAY(),1)
G3:I22G3=ADATE(C3:E22,"f",)
K3:M22K3=ADATE(C3:E22,"e",)
O3:Q22O3=ADATE(C3:E22,"m",)
S3:U22S3=ADATE(C3:E22,"y",)
W3:Y22W3=ARRANGE(C3:E22,{3,1})
AA3:AC22AA3=ADATE(W3#,"m",2)
AF3:AH9AF3=ADVFLT(AA3#,{2,2},{">=2019-03-mar","<=2020-03-mar"},,)
AF14:AH25AF14=ADVFLT(AA3#,,,{2,2},{"<=2019-12-dec",">2020-12-dec"})
G25:I44G25=ADATE(C3:E22,"q",)
K25:M44K25=ADATE(C3:E22,"od",)
O25:Q44O25=ADATE(C3:E22,"om",)
S25:U44S25=ADATE(C3:E22,"oq",)
W25:Y44W25=ADATE(W3#,"oq",2)
AA26:AC37AA26=ADVFLT(W25#,,,{2,2},{"q1","q4"})
AA42:AC49AA42=ACOMBINE(AA26#,{2,3,1})
Dynamic array formulas.
 
Upvote 0
TEXT.NDT does to dates serial numbers, positive or negative, whatever TEXT(sn,"date format") does to regular positive dates serial numbers.
TEXT.NDT(sn,[ft]) Text Format Negative Dates function.
sn: serial numbers array
[ft]: format argument, any of the accepted text patterns for date formats.
- if omitted, pattern => "dd-mm-yyy"
When comes to negative sn, makes sense to use for years, 4 digits representation (at least 3 "y"'s)
Excel Formula:
=LAMBDA(sn, [ft],
    LET(
        f, IF(ft = "", "dd-mm-yyy", ft),
        i, sn > 0,
        s, IF(i, sn, sn + 146098),
        y, YEAR(s),
        t, TEXT(s, f),
        IF(i, t, SUBSTITUTE(t, y, y - 400))
    )
)
Neg sn dates.xlsx
ABCDEFGHIJKLMNOPQ
1
2=RANDARRAY(40,,1600,2022,1)=TEXT.NDT(F6#,"dd-mmm-yyy")
3↓↓↓=RANDARRAY(40,,1,12,1)↓↓↓=TEXT.NDT(F6#,"ddd")
4↓↓↓↓↓↓=RANDARRAY(40,,1,31,1)↓↓↓↓↓↓=--TEXT.NDT(F6#,"d")
5↓↓↓↓↓↓↓↓↓=NDT(B6#,C6#,D6#)=TEXT.NDT(F6#)↓↓↓↓↓↓↓↓↓=--TEXT.NDT(F6#,"m")
61794115-3840605-11-179405-Nov-1794Wed511
71684215-7884615-02-168415-Feb-1684Tue152
8181078-3268308-07-181008-Jul-1810Sun87
91724121-6394701-12-172401-Dec-1724Fri112
1018371025-2271225-10-183725-Oct-1837Wed2510
111617126-10333726-01-161726-Jan-1617Thu261
121800631-3634201-07-180001-Jul-1800Tue17
13160634-10731804-03-160604-Mar-1606Sat43
141895618-165718-06-189518-Jun-1895Tue186
151767627-4839927-06-176727-Jun-1767Sat276
1616261111-9976111-11-162611-Nov-1626Wed1111
171928141023104-01-192804-Jan-1928Wed41
1819894273262527-04-198927-Apr-1989Thu274
1919535271950627-05-195327-May-1953Wed275
20193411171274017-11-193417-Nov-1934Sat1711
21173025-6205505-02-173005-Feb-1730Sun52
22173478-6044108-07-173408-Jul-1734Thu87
23170611-7085601-01-170601-Jan-1706Fri11
2420158104222610-08-201510-Aug-2015Mon108
25186145-1414905-04-186105-Apr-1861Fri54
2619939213423321-09-199321-Sep-1993Tue219
2719602252197125-02-196025-Feb-1960Thu252
281705630-7104130-06-170530-Jun-1705Tue306
29181382-3156202-08-181302-Aug-1813Mon28
301893624-238124-06-189324-Jun-1893Sat246
31196710242476924-10-196724-Oct-1967Tue2410
321819125-2924605-12-181905-Dec-1819Sun512
331732114-6105204-11-173204-Nov-1732Tue411
341911722422122-07-191122-Jul-1911Sat227
351795101-3807601-10-179501-Oct-1795Thu110
3620052113839411-02-200511-Feb-2005Fri112
371683831-7901431-08-168331-Aug-1683Tue318
381694106-7496006-10-169406-Oct-1694Wed610
39182956-2580606-05-182906-May-1829Wed65
401669216-8432316-02-166916-Feb-1669Sat162
4119368151337715-08-193615-Aug-1936Sat158
421822111-2818401-11-182201-Nov-1822Fri111
431750729-5457629-07-175029-Jul-1750Wed297
441813122-3144002-12-181302-Dec-1813Thu212
451651515-9081015-05-165115-May-1651Mon155
46
TEXT.NDT
Cell Formulas
RangeFormula
B2,J2B2=FORMULATEXT(B6)
C3,L3C3=FORMULATEXT(C6)
D4,N4D4=FORMULATEXT(D6)
F5,H5,P5F5=FORMULATEXT(F6)
B6:B45B6=RANDARRAY(40,,1600,2022,1)
C6:C45C6=RANDARRAY(40,,1,12,1)
D6:D45D6=RANDARRAY(40,,1,31,1)
F6:F45F6=NDT(B6#,C6#,D6#)
H6:H45H6=TEXT.NDT(F6#)
J6:J45J6=TEXT.NDT(F6#,"dd-mmm-yyy")
L6:L45L6=TEXT.NDT(F6#,"ddd")
N6:N45N6=--TEXT.NDT(F6#,"d")
P6:P45P6=--TEXT.NDT(F6#,"m")
Dynamic array formulas.
 
Neg sn dates.xlsx
ABCDEFGHIJKLMNOPQ
1Extracting leap years using 29 Feb method if text.ndt(ndt(y,2,29),"m")=2 => leap year
2
3=FILTER(B6#,F6#=2)checking 400y leap cycle
4=RANDARRAY(40,,1600,2500,1)if m=2 => leap year↓↓↓=FILTER(B6#,F6#=3)
5↓↓↓=NDT(B6#,2,29)=--TEXT.NDT(D6#,"m")186020731600leap
62073632493168424941700no
724942170163191219691800no
81969252633202422182000leap
922181162083189620032100no
102003376813240021102200no
111860-145502171621862300no
122110767623224419902400leap
132186104521323402270
14199032933320202061O5:=IF(TEXT.NDT(NDT(M5:M12,2,29),"m")="2","leap","no")
15227013520131625
161684-7883222239
1720615886632133
181912444321641
191625-10038132225
20223912387831745
2121338516332323
221641-9453732130
23222511876531971
241745-5655231738
25232315455831635
2621308406731802
2719712599331611
281738-5910931997
291635-9672931786
3020244535121635
311896-140122402
321802-3573431830
33240018268222303
341716-6714522221
351611-1054953
361997354903
371786-415773
3822441257042
391635-967293
4023401607672
4124021834133
421830-255073
4323031472533
442020438902
4522211173043
46
TEXT.NDT 1
Cell Formulas
RangeFormula
H3,B4H3=FORMULATEXT(H5)
J4,D5,F5J4=FORMULATEXT(J5)
H5:H14H5=FILTER(B6#,F6#=2)
J5:J34J5=FILTER(B6#,F6#=3)
O5:O12O5=IF(TEXT.NDT(NDT(M5:M12,2,29),"m")="2","leap","no")
B6:B45B6=RANDARRAY(40,,1600,2500,1)
D6:D45D6=NDT(B6#,2,29)
F6:F45F6=--TEXT.NDT(D6#,"m")
M14M14=FORMULATEXT(O5)
Dynamic array formulas.
 
NDT.TEXT returns sn of an array of dates properly formatted as text. Does what --(text) does to positive dates formatted as text.
NDT.TEXT(tx)
tx
: text array
Excel Formula:
=LAMBDA(tx,
    LET(
        r, REDUCE(tx, SEQUENCE(300, , 1600), LAMBDA(v, i, SUBSTITUTE(v, i, i + 400))),
        IFERROR(--tx, --r - 146098)
    )
)
Neg sn dates.xlsx
ABCDEFGHIJKLMNOPQ
1NDT.TEXT(tx)
2
3random sn's
4=RANDARRAY(3,15,-109572,TODAY(),1)
5-13778-10836-11319-102627414523825-3355-4525-75218-4397-36706-56334-6326614999-64159
6-5450714391-46339-32841-74104417911273-10742412770-23083-108023-270073281-52373-39085
7136466-3635-17884-31825-99509-48002-446476865-60899-102063-58117-29379-3766423649390
8
9=TEXT.NDT(B5#)
1011-04-186201-05-187003-01-186906-01-161927-06-201321-06-191024-10-189011-08-188721-01-169417-12-188702-07-179905-10-174513-10-172623-01-194103-05-1724
1106-10-175026-05-193915-02-177331-01-181008-02-169701-06-201426-06-190318-11-160517-12-193419-10-183629-03-160421-01-182624-12-190809-08-175626-12-1792
1202-11-199917-01-189013-01-185112-11-181221-07-162728-07-176804-10-177717-10-191806-04-173323-07-162017-11-174025-07-181916-11-179621-06-190615-09-1925
13
14=TEXT.NDT(B5#,"d-mmm-yyy")
1511-Apr-18621-May-18703-Jan-18696-Jan-161927-Jun-201321-Jun-191024-Oct-189011-Aug-188721-Jan-169417-Dec-18872-Jul-17995-Oct-174513-Oct-172623-Jan-19413-May-1724
166-Oct-175026-May-193915-Feb-177331-Jan-18108-Feb-16971-Jun-201426-Jun-190318-Nov-160517-Dec-193419-Oct-183629-Mar-160421-Jan-182624-Dec-19089-Aug-175626-Dec-1792
172-Nov-199917-Jan-189013-Jan-185112-Nov-181221-Jul-162728-Jul-17684-Oct-177717-Oct-19186-Apr-173323-Jul-162017-Nov-174025-Jul-181916-Nov-179621-Jun-190615-Sep-1925
18
19=NDT.TEXT(B10#)
20-13778-10836-11319-102627414523825-3355-4525-75218-4397-36706-56334-6326614999-64159
21-5450714391-46339-32841-74104417911273-10742412770-23083-108023-270073281-52373-39085
22236466-3635-17884-31825-99509-48002-446476865-60899-102063-58117-29379-3766423649390
23
24=NDT.TEXT(B15#)
25-13778-10836-11319-102627414523825-3355-4525-75218-4397-36706-56334-6326614999-64159
26-5450714391-46339-32841-74104417911273-10742412770-23083-108023-270073281-52373-39085
27336466-3635-17884-31825-99509-48002-446476865-60899-102063-58117-29379-3766423649390
28
29check if all 3 sn's arrays are identical
30=SUM(B20#-B5#+B25#-B5#)=0
31TRUE
32
NDT.TEXT
Cell Formulas
RangeFormula
B4,B30,B24,B19,B14,B9B4=FORMULATEXT(B5)
B5:P7B5=RANDARRAY(3,15,-109572,TODAY(),1)
B10:P12B10=TEXT.NDT(B5#)
B15:P17B15=TEXT.NDT(B5#,"d-mmm-yyy")
B20:P22,B25:P27B20=NDT.TEXT(B10#)
B31B31=SUM(B20#-B5#+B25#-B5#)=0
Dynamic array formulas.
 
Neg sn dates.xlsx
ABCDEFGHIJKLMNOPQ
1FOM and EOM for an array of sn (negative or positive)
2random sn's
3=RANDARRAY(3,15,-109572,TODAY(),1)
4-47349-75662-19902-59596-78183-83444-7740143074-23583-101957-92138-106755-81287-50272-78805
5-79060-23893-33216139-80032-7839941448-85290-12038-76180-52550-92619-847713658626467
6-1034487768-52155-66979-4114617784-58278-62823-1041411988-29270-4368033448-81224-97307
7
8full date of sn
9=TEXT.NDT(B4#,"d-m-yyy")
1012-5-17703-11-16925-7-184530-10-17369-12-168515-7-167130-1-16885-12-20177-6-18356-11-162025-9-164718-9-160710-6-167711-5-176227-3-1684
1116-7-16831-8-183421-1-180918-5-190016-11-16807-5-168523-6-201325-6-166615-1-18674-6-169114-2-17561-6-164626-11-16671-3-200017-6-1972
127-10-16167-4-192115-3-175713-8-17166-5-17878-9-19489-6-174030-12-172727-6-187126-10-193211-11-181928-5-178029-7-199112-8-167731-7-1633
13
14sn's 1st of month (FOM)
15=NDT.TEXT(TEXT.NDT(B4#,"m-yyy"))
16-47360-75664-19906-59625-78191-83458-7743043070-23589-101962-92162-106772-81296-50282-78831
17-79075-23893-33236122-80047-7840541426-85314-12052-76183-52563-92619-847963658626451
18-1034547762-52169-66991-4115117777-58286-62852-1044011963-29280-4370733420-81235-97337
19
20check FOM
21=TEXT.NDT(B16#)
2201-05-177001-11-169201-07-184501-10-173601-12-168501-07-167101-01-168801-12-201701-06-183501-11-162001-09-164701-09-160701-06-167701-05-176201-03-1684
2301-07-168301-08-183401-01-180901-05-190001-11-168001-05-168501-06-201301-06-166601-01-186701-06-169101-02-175601-06-164601-11-166701-03-200001-06-1972
2401-10-161601-04-192101-03-175701-08-171601-05-178701-09-194801-06-174001-12-172701-06-187101-10-193201-11-181901-05-178001-07-199101-08-167701-07-1633
25
26sn's end of month(EOM) (a separate function can be designed if needed)
27=NDT(--TEXT.NDT(B4#,"yyy"),TEXT.NDT(B4#,"m")+1,1)-1
28-47330-75635-19876-59595-78161-83428-7740043100-23560-101933-92133-106743-81267-50252-78801
29-79045-23863-33206152-80018-7837541455-85285-12022-76154-52535-92590-847673661626480
30-1034247791-52139-66961-4112117806-58257-62822-1041111993-29251-4367733450-81205-97307
31
32check EOM
33=TEXT.NDT(B28#)
3431-05-177030-11-169231-07-184531-10-173631-12-168531-07-167131-01-168831-12-201730-06-183530-11-162030-09-164730-09-160730-06-167731-05-176231-03-1684
3531-07-168331-08-183431-01-180931-05-190030-11-168031-05-168530-06-201330-06-166631-01-186730-06-169129-02-175630-06-164630-11-166731-03-200030-06-1972
3631-10-161630-04-192131-03-175731-08-171631-05-178730-09-194830-06-174031-12-172730-06-187131-10-193230-11-181931-05-178031-07-199131-08-167731-07-1633
37
NDT.TEXT 1
Cell Formulas
RangeFormula
B3,B33,B27,B21,B15,B9B3=FORMULATEXT(B4)
B4:P6B4=RANDARRAY(3,15,-109572,TODAY(),1)
B10:P12B10=TEXT.NDT(B4#,"d-m-yyy")
B16:P18B16=NDT.TEXT(TEXT.NDT(B4#,"m-yyy"))
B22:P24,B34:P36B22=TEXT.NDT(B16#)
B28:P30B28=NDT(--TEXT.NDT(B4#,"yyy"),TEXT.NDT(B4#,"m")+1,1)-1
Dynamic array formulas.
 
Neg sn dates.xlsx
ABCDEFGHIJKLMN
1Dates array sorting
2=SORTBY(B4:B43,NDT.TEXT(B4:B43))
3↓↓↓=TEXT.NDT(SORT(NDT.TEXT(B4:B43)),"dd-mmm-yyy")
415-May-164202-Mar-162202-Mar-1622
514-Nov-169304-Dec-163504-Dec-1635days between d1 d2
619-Apr-182326-Sep-163726-Sep-1637d101-08-22 <-- numeric value under date format façade
720-Jun-187315-May-164215-May-1642d231-08-1777 <-- dates before 1900 always imputed with 4 digits year
822-Nov-188122-Dec-165022-Dec-1650
920-Mar-173811-Feb-165311-Feb-1653=I6-NDT.TEXT(I7)<-- when 29feb1900 inside dates interval
1012-Aug-169830-Jan-165830-Jan-165889455we do not need the final +1
1105-Apr-185616-Dec-167616-Dec-1676
1202-Nov-188010-Jan-168310-Jan-1683d131-Aug-1777
1323-Sep-197826-Jan-168626-Jan-1686d215-7-1650
1416-Dec-167614-Nov-169314-Nov-1693
1504-Mar-192109-Feb-169509-Feb-1695=NDT.TEXT(I12)-NDT.TEXT(I13)+1
1610-Jan-168312-Aug-169812-Aug-169846434
1704-Dec-163520-Mar-173820-Mar-1738
1826-Sep-163702-Jun-178202-Jun-1782sn of today's date 350y ago
1926-Jan-168608-Dec-181408-Dec-1814=LET(d,TODAY(),NDT(YEAR(d)-350,MONTH(d),DAY(d)))
2019-Jul-188819-Apr-182319-Apr-1823-83019
2108-Dec-181407-Sep-184607-Sep-1846
2210-Apr-193403-Jan-185303-Jan-1853check
2303-May-200105-Apr-185605-Apr-1856=TEXT.NDT(I20)
2422-Dec-165027-Jul-186827-Jul-186812-09-1672
2509-Feb-169524-Jan-187124-Jan-1871
2616-Feb-191420-Jun-187320-Jun-1873negative dates formulas can deal also with time
2726-Apr-187826-Apr-187826-Apr-187817-8-1634 13:45
2830-Jan-165802-Nov-188002-Nov-1880
2916-Apr-197914-Nov-188014-Nov-1880=NDT.TEXT(I27)
3014-Nov-188022-Nov-188122-Nov-1881-96924.42708
3120-Aug-190619-Jul-188819-Jul-1888
3211-Jun-191501-Jul-190601-Jul-1906check
3301-Jul-190620-Aug-190620-Aug-1906=TEXT.NDT(I30,"d-mmm-yyy hh:mm")
3402-Mar-162215-Jan-191015-Jan-191017-Aug-1634 13:45
3515-Jan-191016-Feb-191416-Feb-1914
3624-Jan-187111-Jun-191511-Jun-1915
3711-Feb-165304-Mar-192104-Mar-1921
3813-Jan-192913-Jan-192913-Jan-1929
3903-Apr-193510-Apr-193410-Apr-1934
4002-Jun-178203-Apr-193503-Apr-1935
4107-Sep-184623-Sep-197823-Sep-1978
4227-Jul-186816-Apr-197916-Apr-1979
4303-Jan-185303-May-200103-May-2001
44
NDT.TEXT 2
Cell Formulas
RangeFormula
D2D2=FORMULATEXT(D4)
F3,I33,I29,I23,I19,I15,I9F3=FORMULATEXT(F4)
D4:D43D4=SORTBY(B4:B43,NDT.TEXT(B4:B43))
F4:F43F4=TEXT.NDT(SORT(NDT.TEXT(B4:B43)),"dd-mmm-yyy")
I10I10=I6-NDT.TEXT(I7)
I16I16=NDT.TEXT(I12)-NDT.TEXT(I13)+1
I20I20=LET(d,TODAY(),NDT(YEAR(d)-350,MONTH(d),DAY(d)))
I24I24=TEXT.NDT(I20)
I30I30=NDT.TEXT(I27)
I34I34=TEXT.NDT(I30,"d-mmm-yyy hh:mm")
Dynamic array formulas.
 
Mike's latest YT
Remembered that I have covered that here ,2 years ago.
concept: this very thread few posts above: post #8 ADATE
lambdas: TEXT.NDT post#11
Excel Formula:
=LAMBDA(sn, [ft],
    LET(
        f, IF(ft = "", "dd-mm-yyy", ft),
        i, sn > 0,
        s, IF(i, sn, sn + 146098),
        y, YEAR(s),
        t, TEXT(s, f),
        IF(i, t, SUBSTITUTE(t, y, y - 400))
    )
)
and NDT.TEXT post#13
Excel Formula:
=LAMBDA(tx,
    LET(
        r, REDUCE(tx, SEQUENCE(300, , 1600), LAMBDA(v, i, SUBSTITUTE(v, i, i + 400))),
        IFERROR(--tx, --r - 146098)
    )
)
These formulas create a consistent negative Excel date system.
To add something new, here is a lambda to check leap years between to year values
LEAP(ya,yb) calls NDT.TEXT TEXT.NDT
ya,yb any years >= 1600 (any order) (before Gregorian calendar the calendars were incorrect)
Excel Formula:
=LAMBDA(ya, yb,
    LET(
        y, SEQUENCE(ABS(yb - ya) + 1, , MIN(ya, yb)),
        d, NDT.TEXT("29-02-" & y),
        i, ISNUMBER(d),
        f, FILTER(d, i),
        HSTACK(FILTER(y, i), f, TEXT.NDT(f, "ddd dd-mmm-yyy"))
    )
)
NOTE: For US dates, we have only to use correspondent date format and everything will work fine (all years should have 4 digits)
leep years check link List of leap years and leap days since 1600

EMT 1864.xlsx
ABCDEFGHIJKLMNOPQR
1Excel negative dates system (must be consistent with Excel date system, continues with negative numbers in order, and retains the 29 Feb 1900 anomaly, everything else acurate after 1-jan-1600)
2
3=NDT.TEXT(B5:B11)
4text values↓↓↓↓=TEXT.NDT(C5#,"ddd mmm-dd-yyyy")=LEAP(1600,1720)=LEAP(1810,1720)=LEAP(1880,1920)
502-01-19002Mon Jan-02-1900*11600-109513Tue 29-Feb-16001720-65684Thu 29-Feb-17201880-7245Sun 29-Feb-1880
601-01-19001Sun Jan-01-19001604-108052Sun 29-Feb-16041724-64223Tue 29-Feb-17241884-5784Fri 29-Feb-1884
731-12-18990Sun Dec-31-18991608-106591Fri 29-Feb-16081728-62762Sun 29-Feb-17281888-4323Wed 29-Feb-1888
830-12-1899-1Sat Dec-30-18991612-105130Wed 29-Feb-16121732-61301Fri 29-Feb-17321892-2862Mon 29-Feb-1892
901-01-1800-36523Wed Jan-01-18001616-103669Mon 29-Feb-16161736-59840Wed 29-Feb-17361896-1401Sat 29-Feb-1896
1001-01-1700-73047Fri Jan-01-17001620-102208Sat 29-Feb-16201740-58379Mon 29-Feb-1740*190060Wed 29-Feb-1900excel anomaly
1101-01-1600-109572Sat Jan-01-16001624-100747Thu 29-Feb-16241744-56918Sat 29-Feb-174419041521Mon 29-Feb-1904
121628-99286Tue 29-Feb-16281748-55457Thu 29-Feb-174819082982Sat 29-Feb-1908
13PQ to Excel and vice versa for sn values <=601632-97825Sun 29-Feb-16321752-53996Tue 29-Feb-175219124443Thu 29-Feb-1912
141636-96364Fri 29-Feb-16361756-52535Sun 29-Feb-175619165904Tue 29-Feb-1916
15PQ snPQ date1640-94903Wed 29-Feb-16401760-51074Fri 29-Feb-176019207365Sun 29-Feb-1920
16-10258912-02-16191644-93442Mon 29-Feb-16441764-49613Wed 29-Feb-1764
171648-91981Sat 29-Feb-16481768-48152Mon 29-Feb-1768=LEAP(2017,1990)
18To find the date if we have the PQ sn we have to subtract 11652-90520Thu 29-Feb-16521772-46691Sat 29-Feb-1772199233663Sat 29-Feb-1992
191656-89059Tue 29-Feb-16561776-45230Thu 29-Feb-1776199635124Thu 29-Feb-1996
20=TEXT.NDT(B16-1)1660-87598Sun 29-Feb-16601780-43769Tue 29-Feb-1780*200036585Tue 29-Feb-2000
21PQ sn to date12-02-16191664-86137Fri 29-Feb-16641784-42308Sun 29-Feb-1784200438046Sun 29-Feb-2004
221668-84676Wed 29-Feb-16681788-40847Fri 29-Feb-1788200839507Fri 29-Feb-2008
23To find the PQ sn if we have date we have to add 11672-83215Mon 29-Feb-16721792-39386Wed 29-Feb-1792201240968Wed 29-Feb-2012
241676-81754Sat 29-Feb-1676*1796-37925Mon 29-Feb-1796201642429Mon 29-Feb-2016
25=NDT.TEXT(C16)+11680-80293Thu 29-Feb-16801804-35004Wed 29-Feb-1804
26-102589date to PQ sn1684-78832Tue 29-Feb-16841808-33543Mon 29-Feb-1808*1900 should not be leap year but in Excel it is
271688-77371Sun 29-Feb-1688*2000 is a leap year
281692-75910Fri 29-Feb-1692*1800 not leap year
29*21696-74449Wed 29-Feb-1696
301704-71528Fri 29-Feb-1704
311708-70067Wed 29-Feb-1708
321712-68606Mon 29-Feb-1712
331716-67145Sat 29-Feb-1716
341720-65684Thu 29-Feb-1720
35
36*1 1600 is leap year
37*2 1700 not leap year
38
Sheet1
Cell Formulas
RangeFormula
C3C3=FORMULATEXT(C5)
D4,B25,C20,O17,O4,K4,G4D4=FORMULATEXT(D5)
C5:C11C5=NDT.TEXT(B5:B11)
D5:D11D5=TEXT.NDT(C5#,"ddd mmm-dd-yyyy")
G5:I34G5=LEAP(1600,1720)
K5:M26K5=LEAP(1810,1720)
O5:Q15O5=LEAP(1880,1920)
O18:Q24O18=LEAP(2017,1990)
C21C21=TEXT.NDT(B16-1)
B26B26=NDT.TEXT(C16)+1
Dynamic array formulas.
 
Wow!!!! Historians are now so happy to have your LAMBDAs NDT, NDT.TEXT and TEXT.NDT to create a consistent negative Excel date system. ExcelLambda, you much better and smarter than the programmers at MS lol

Thanks for bringing the Team such LAMBDA power : )
 
I tested it and got these results:

Text Date12-25-1700
NDT =NDT(1700,12,25)
-72689​
NDT .TEXT =NDT.TEXT("12-25-1700")
-72689​
TEXT.NDT =TEXT.NDT(C60,"mmm-dd-yyy")Dec-25-1700

Now I am like: "Wow^100" : ) : )
 
Thank you, Mike, for your kind words and for testing that the negative dates functions are also consistent with US dates formats.
More consistency tests and fun fact about DATE:
EMT 1864.xlsx
ABCDEFGHI
1
2Another proof that NDT is as consistent as DATE function is, same behavior
3
4Date behavior when explicit date values do not exist like day 32 month 13
5=DATE(2024,13,32)=TEXT(B6,"ddd dd-mmm-yyy")
645689Sat 01-Feb-2025
7
8Same inexisting values but 400 years before.
9=NDT(1624,13,32)=TEXT.NDT(B10,"ddd dd-mmm-yyy")
10-100409Sat 01-Feb-1625
11
12As we see , same day, same month, same wkdy, only 400 years before
13If consistent, days gap coresponding to 400 years should be 146098
14=B6-B10
15146098
16
17NDT and DATE "catch up" alike when dates values are "offset"
18
19Also same behavior when date text format is not an existing date. (2021 1621 not leap years)
20=--(B21)
2129-Feb-2021#VALUE!
22
23=NDT.TEXT(B24)
2429-Feb-1621#VALUE!
25
2628 Feb has no probl.
27=NDT.TEXT(B28)=TEXT.NDT(D28,"ddd dd-mm-yyy")
2828-Feb-1621-101843Sun 28-02-1621
29
30Fun fact: when as year argument of DATE is <1900 DATE adds 1900 to it
31
32=DATE(1800,1,1)=TEXT(B33,"dd-mmm-yyy")
3365743901-Jan-3700
34
35=1800+1900
363700
37
Sheet2
Cell Formulas
RangeFormula
B5,D5,E35,E32,B32,D27:E27,D23,D20,B14,B9,D9B5=FORMULATEXT(B6)
B6B6=DATE(2024,13,32)
D6D6=TEXT(B6,"ddd dd-mmm-yyy")
B10B10=NDT(1624,13,32)
D10D10=TEXT.NDT(B10,"ddd dd-mmm-yyy")
B15B15=B6-B10
D21D21=--(B21)
D24,D28D24=NDT.TEXT(B24)
E28E28=TEXT.NDT(D28,"ddd dd-mm-yyy")
B33B33=DATE(1800,1,1)
E33E33=TEXT(B33,"dd-mmm-yyy")
E36E36=1800+1900
 
The NDT nonexistence and offsetting is cooler than the other side of the pillow, sorta like XlLambda : ) : ) : ) : )
 

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top