# From day of year get the fool date

• ### Question

• Hello

Pls, How i get the fool date from this scripte?!

```cls

\$year = "2019"

\$array = 1..29 |% {
if ((\$cd - \$_) % 7 -eq 1){
}
}

[string]\$array0 = \$array[0]
\$array0+" days from 1.1."+\$year

[string]\$array1 = \$array[1]
\$array1+" days from 1.1."+\$year

[string]\$array2 = \$array[2]
\$array2+" days from 1.1."+\$year

[string]\$array3 = \$array[1]
\$array3+" days from 1.1."+\$year```

I get:

356 days from 1.1.2019

349 days from 1.1.2019

342 days from 1.1.2019

349 days from 1.1.2019

Now the fool date is for each is?

Arnold

• Edited by Tuesday, December 10, 2019 5:10 PM
Tuesday, December 10, 2019 5:08 PM

• ```\$year = "2019"

\$array = 1..29 |% {
if ((\$cd - \$_) % 7 -eq 1){
}
}

[string]\$array0 = \$array[0]
\$array0+" days from 1.1."+\$year

[string]\$array1 = \$array[1]
\$array1+" days from 1.1."+\$year

[string]\$array2 = \$array[2]
\$array2+" days from 1.1."+\$year

[string]\$array3 = \$array[3]
\$array3+" days from 1.1."+\$year
""
(Get-Date -Year 2019 -Month 12 -Day 1).DayOfYear # 335
(Get-Date -Year 2019 -Month 12 -Day 8).DayOfYear # 342
(Get-Date -Year 2019 -Month 12 -Day 15).DayOfYear# 349
(Get-Date -Year 2019 -Month 12 -Day 22).DayOfYear# 356```
With contrôle..

Thanks !

• Marked as answer by Tuesday, December 10, 2019 9:50 PM
• Unmarked as answer by Tuesday, December 10, 2019 9:53 PM
• Edited by Tuesday, December 10, 2019 9:55 PM
• Marked as answer by Tuesday, December 10, 2019 9:56 PM
Tuesday, December 10, 2019 9:50 PM

### All replies

• What is "fool" date? Do you mean this like "the old fool" or "April fool"?

Please tell us what the purpose of this is.

\_(ツ)_/

Tuesday, December 10, 2019 6:09 PM
• Hu,

```\$year = "2019"

\$array = 1..29 |% {
if ((\$cd - \$_) % 7 -eq 1){
}
}

[string]\$array0 = \$array[0]
\$array0+" days from 1.1."+\$year

[string]\$array1 = \$array[1]
\$array1+" days from 1.1."+\$year

[string]\$array2 = \$array[2]
\$array2+" days from 1.1."+\$year

[string]\$array3 = \$array[3]
\$array3+" days from 1.1."+\$year```

The whole date of these days

356

349

342

335

Thanks Arnold

Tuesday, December 10, 2019 7:30 PM
• Tuesday, December 10, 2019 8:51 PM
• OAD is not a Gregorian date.

In PowerShell it is a simple addition problem returning a timespan converted to milliseconds.

\_(ツ)_/

Tuesday, December 10, 2019 9:04 PM
• Hu,

```\$year = "2019"

\$array = 1..29 |% {
if ((\$cd - \$_) % 7 -eq 1){
}
}

[string]\$array0 = \$array[0]
\$array0+" days from 1.1."+\$year

[string]\$array1 = \$array[1]
\$array1+" days from 1.1."+\$year

[string]\$array2 = \$array[2]
\$array2+" days from 1.1."+\$year

[string]\$array3 = \$array[3]
\$array3+" days from 1.1."+\$year```

The whole date of these days

356

349

342

335

Thanks Arnold

You cannot get a "FULL" date from an integer.  There is no information.  If you want the relative data use "AddDays" and add to the original date.

\_(ツ)_/

Tuesday, December 10, 2019 9:07 PM
• ```\$year = "2019"

\$array = 1..29 |% {
if ((\$cd - \$_) % 7 -eq 1){
}
}

[string]\$array0 = \$array[0]
\$array0+" days from 1.1."+\$year

[string]\$array1 = \$array[1]
\$array1+" days from 1.1."+\$year

[string]\$array2 = \$array[2]
\$array2+" days from 1.1."+\$year

[string]\$array3 = \$array[3]
\$array3+" days from 1.1."+\$year
""
(Get-Date -Year 2019 -Month 12 -Day 1).DayOfYear # 335
(Get-Date -Year 2019 -Month 12 -Day 8).DayOfYear # 342
(Get-Date -Year 2019 -Month 12 -Day 15).DayOfYear# 349
(Get-Date -Year 2019 -Month 12 -Day 22).DayOfYear# 356```
With contrôle..

Thanks !

• Marked as answer by Tuesday, December 10, 2019 9:50 PM
• Unmarked as answer by Tuesday, December 10, 2019 9:53 PM
• Edited by Tuesday, December 10, 2019 9:55 PM
• Marked as answer by Tuesday, December 10, 2019 9:56 PM
Tuesday, December 10, 2019 9:50 PM
• Why? What is the purpose of just going in a circle? Why use OAD for this.

\_(ツ)_/

Tuesday, December 10, 2019 10:45 PM
• Hi,

The error is fool = foul Date. (en entièr, im ganzen ect.)

```cls
\$year = "2019"

\$array = 1..28 |% {
if ((\$cd - \$_) % 7 -eq 1){
}
}
""
" 	1. "+\$array[3]
" 	2. "+\$array[2]
" 	3. "+\$array[1]
" 	4. "+\$array[0]```

I have solve the probleme: with "tolongdatestring()"

1. dimanche 1 décembre 2019

2. dimanche 8 décembre 2019

3. dimanche 15 décembre 2019

4. dimanche 22 décembre 2019

Thx Sir

Arnold

Tuesday, December 10, 2019 11:46 PM
• Arnold. You need to learn what a date is and what a datetime object is. Computers are not text bas3ed. PowerShell is object based.

"fool" and "foul" are not date words or properties in any language.

I also recommend taking some time to learn PowerShell and how PowerShell is an obect system.

Start here for a simple definition of this: https://en.wikipedia.org/wiki/Object_(computer_science)

\_(ツ)_/

Wednesday, December 11, 2019 12:21 AM