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.png3.png2.png4.png2.png3.png
Today51
Yesterday1731
This week8551
This month13713
Total3432423

Visitor Info

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

Who Is Online

4
Online

czwartek, 08 styczeń 2026 00:50

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