INFORMATICS

The Best

Przełącznik języka

Zaproś mnie na KAWE

Jeżeli podoba Ci się strona i chcesz wspomóc projekt!

Postaw mi kawę na buycoffee.to

This Site

Płatnik

CMS

Hardware

Uncategorised

Emulators

Powershell

Storage Array

DNS

Antivirus program

Licznik

3.png4.png9.png3.png0.png7.png4.png
Today783
Yesterday1609
This week13064
This month27152
Total3493074

Visitor Info

  • IP: 10.1.71.219
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

4
Online

sobota, 21 luty 2026 11:36

Add date fo file name

Gwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywna
 
 

I usually do it this way whenever I need a date/time string:

SHOW actual settings
echo %DATE%
23.11.2022
echo %time%
13:21:03,46

SET backup_file_name=%COMPUTERNAME%.%date:~6,4%-%date:~3,2%-%date:~0,2%_h_%time:~0,2%-%time:~3,2%.PGDMP

set dt=%DATE:~6,4%_%DATE:~3,2%_%DATE:~0,2%__%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2% set dt=%dt: =0%

The resulting string has the format: - SrvPoint.SrvPOINT.1-23-2--20_h_11-16.PGDMP


Short explanation of how substrings work:

%VARIABLE:~num_chars_to_skip,num_chars_to_keep%

So to get just the year from a date like "23.11.2022" use:

%DATE:~6,4%
       ^-----skip 6 characters
         ^---keep 4 characters 

 

Search